aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/phy
diff options
context:
space:
mode:
authorGrygorii Strashko <grygorii.strashko@ti.com>2018-11-19 20:24:20 -0500
committerKishon Vijay Abraham I <kishon@ti.com>2018-12-11 23:31:33 -0500
commit79a5a18aa9d1062205cdcfa183d4cd5241d1b8da (patch)
tree5a3f45db4914c1bd127adabeb86144e35bbfad3a /include/linux/phy
parent640ac14744862b8b95652e7bc38b4ee987fa5eaf (diff)
phy: core: rework phy_set_mode to accept phy mode and submode
Currently the attempt to add support for Ethernet interface mode PHY (MII/GMII/RGMII) will lead to the necessity of extending enum phy_mode and duplicate there values from phy_interface_t enum (or introduce more PHY callbacks) [1]. Both approaches are ineffective and would lead to fast bloating of enum phy_mode or struct phy_ops in the process of adding more PHYs for different subsystems which will make them unmaintainable. As discussed in [1] the solution could be to introduce dual level PHYs mode configuration - PHY mode and PHY submode. The PHY mode will define generic PHY type (subsystem - PCIE/ETHERNET/USB_) while the PHY submode - subsystem specific interface mode. The last is usually already defined in corresponding subsystem headers (phy_interface_t for Ethernet, enum usb_device_speed for USB). This patch is cumulative change which refactors PHY framework code to support dual level PHYs mode configuration - PHY mode and PHY submode. It extends .set_mode() callback to support additional parameter "int submode" and converts all corresponding PHY drivers to support new .set_mode() callback declaration. The new extended PHY API int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode) is introduced to support dual level PHYs mode configuration and existing phy_set_mode() API is converted to macros, so PHY framework consumers do not need to be changed (~21 matches). [1] http://lkml.kernel.org/r/d63588f6-9ab0-848a-5ad4-8073143bd95d@ti.com Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Diffstat (limited to 'include/linux/phy')
-rw-r--r--include/linux/phy/phy.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 03b319f89a34..b17e7709c5dc 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -60,7 +60,7 @@ struct phy_ops {
60 int (*exit)(struct phy *phy); 60 int (*exit)(struct phy *phy);
61 int (*power_on)(struct phy *phy); 61 int (*power_on)(struct phy *phy);
62 int (*power_off)(struct phy *phy); 62 int (*power_off)(struct phy *phy);
63 int (*set_mode)(struct phy *phy, enum phy_mode mode); 63 int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
64 int (*reset)(struct phy *phy); 64 int (*reset)(struct phy *phy);
65 int (*calibrate)(struct phy *phy); 65 int (*calibrate)(struct phy *phy);
66 struct module *owner; 66 struct module *owner;
@@ -164,7 +164,10 @@ int phy_init(struct phy *phy);
164int phy_exit(struct phy *phy); 164int phy_exit(struct phy *phy);
165int phy_power_on(struct phy *phy); 165int phy_power_on(struct phy *phy);
166int phy_power_off(struct phy *phy); 166int phy_power_off(struct phy *phy);
167int phy_set_mode(struct phy *phy, enum phy_mode mode); 167int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
168#define phy_set_mode(phy, mode) \
169 phy_set_mode_ext(phy, mode, 0)
170
168static inline enum phy_mode phy_get_mode(struct phy *phy) 171static inline enum phy_mode phy_get_mode(struct phy *phy)
169{ 172{
170 return phy->attrs.mode; 173 return phy->attrs.mode;
@@ -278,13 +281,17 @@ static inline int phy_power_off(struct phy *phy)
278 return -ENOSYS; 281 return -ENOSYS;
279} 282}
280 283
281static inline int phy_set_mode(struct phy *phy, enum phy_mode mode) 284static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
285 int submode)
282{ 286{
283 if (!phy) 287 if (!phy)
284 return 0; 288 return 0;
285 return -ENOSYS; 289 return -ENOSYS;
286} 290}
287 291
292#define phy_set_mode(phy, mode) \
293 phy_set_mode_ext(phy, mode, 0)
294
288static inline enum phy_mode phy_get_mode(struct phy *phy) 295static inline enum phy_mode phy_get_mode(struct phy *phy)
289{ 296{
290 return PHY_MODE_INVALID; 297 return PHY_MODE_INVALID;