mvebu: set kernel testing version to 5.4
[openwrt/staging/chunkeey.git] / target / linux / mvebu / patches-5.4 / 541-phy-core-rework-phy_set_mode-to-accept-phy-mode-and-.patch
1 From 79a5a18aa9d1062205cdcfa183d4cd5241d1b8da Mon Sep 17 00:00:00 2001
2 From: Grygorii Strashko <grygorii.strashko@ti.com>
3 Date: Mon, 19 Nov 2018 19:24:20 -0600
4 Subject: [PATCH] phy: core: rework phy_set_mode to accept phy mode and submode
5
6 Currently the attempt to add support for Ethernet interface mode PHY
7 (MII/GMII/RGMII) will lead to the necessity of extending enum phy_mode and
8 duplicate there values from phy_interface_t enum (or introduce more PHY
9 callbacks) [1]. Both approaches are ineffective and would lead to fast
10 bloating of enum phy_mode or struct phy_ops in the process of adding more
11 PHYs for different subsystems which will make them unmaintainable.
12
13 As discussed in [1] the solution could be to introduce dual level PHYs mode
14 configuration - PHY mode and PHY submode. The PHY mode will define generic
15 PHY type (subsystem - PCIE/ETHERNET/USB_) while the PHY submode - subsystem
16 specific interface mode. The last is usually already defined in
17 corresponding subsystem headers (phy_interface_t for Ethernet, enum
18 usb_device_speed for USB).
19
20 This patch is cumulative change which refactors PHY framework code to
21 support dual level PHYs mode configuration - PHY mode and PHY submode. It
22 extends .set_mode() callback to support additional parameter "int submode"
23 and converts all corresponding PHY drivers to support new .set_mode()
24 callback declaration.
25 The new extended PHY API
26 int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode)
27 is introduced to support dual level PHYs mode configuration and existing
28 phy_set_mode() API is converted to macros, so PHY framework consumers do
29 not need to be changed (~21 matches).
30
31 [1] http://lkml.kernel.org/r/d63588f6-9ab0-848a-5ad4-8073143bd95d@ti.com
32 Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
33 Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
34 ---
35 drivers/phy/allwinner/phy-sun4i-usb.c | 3 ++-
36 drivers/phy/amlogic/phy-meson-gxl-usb2.c | 5 +++--
37 drivers/phy/amlogic/phy-meson-gxl-usb3.c | 5 +++--
38 drivers/phy/marvell/phy-mvebu-cp110-comphy.c | 3 ++-
39 drivers/phy/mediatek/phy-mtk-tphy.c | 2 +-
40 drivers/phy/mediatek/phy-mtk-xsphy.c | 2 +-
41 drivers/phy/mscc/phy-ocelot-serdes.c | 2 +-
42 drivers/phy/phy-core.c | 6 +++---
43 drivers/phy/qualcomm/phy-qcom-qmp.c | 3 ++-
44 drivers/phy/qualcomm/phy-qcom-qusb2.c | 3 ++-
45 drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c | 3 ++-
46 drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c | 3 ++-
47 drivers/phy/qualcomm/phy-qcom-usb-hs.c | 3 ++-
48 drivers/phy/ti/phy-da8xx-usb.c | 3 ++-
49 drivers/phy/ti/phy-tusb1210.c | 2 +-
50 include/linux/phy/phy.h | 13 ++++++++++---
51 16 files changed, 39 insertions(+), 22 deletions(-)
52
53 --- a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
54 +++ b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
55 @@ -512,7 +512,8 @@ static int mvebu_comphy_power_on(struct
56 return ret;
57 }
58
59 -static int mvebu_comphy_set_mode(struct phy *phy, enum phy_mode mode)
60 +static int mvebu_comphy_set_mode(struct phy *phy,
61 + enum phy_mode mode, int submode)
62 {
63 struct mvebu_comphy_lane *lane = phy_get_drvdata(phy);
64
65 --- a/drivers/phy/phy-core.c
66 +++ b/drivers/phy/phy-core.c
67 @@ -360,7 +360,7 @@ int phy_power_off(struct phy *phy)
68 }
69 EXPORT_SYMBOL_GPL(phy_power_off);
70
71 -int phy_set_mode(struct phy *phy, enum phy_mode mode)
72 +int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode)
73 {
74 int ret;
75
76 @@ -368,14 +368,14 @@ int phy_set_mode(struct phy *phy, enum p
77 return 0;
78
79 mutex_lock(&phy->mutex);
80 - ret = phy->ops->set_mode(phy, mode);
81 + ret = phy->ops->set_mode(phy, mode, submode);
82 if (!ret)
83 phy->attrs.mode = mode;
84 mutex_unlock(&phy->mutex);
85
86 return ret;
87 }
88 -EXPORT_SYMBOL_GPL(phy_set_mode);
89 +EXPORT_SYMBOL_GPL(phy_set_mode_ext);
90
91 int phy_reset(struct phy *phy)
92 {
93 --- a/include/linux/phy/phy.h
94 +++ b/include/linux/phy/phy.h
95 @@ -62,7 +62,7 @@ struct phy_ops {
96 int (*exit)(struct phy *phy);
97 int (*power_on)(struct phy *phy);
98 int (*power_off)(struct phy *phy);
99 - int (*set_mode)(struct phy *phy, enum phy_mode mode);
100 + int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
101 int (*reset)(struct phy *phy);
102 int (*calibrate)(struct phy *phy);
103 struct module *owner;
104 @@ -166,7 +166,10 @@ int phy_init(struct phy *phy);
105 int phy_exit(struct phy *phy);
106 int phy_power_on(struct phy *phy);
107 int phy_power_off(struct phy *phy);
108 -int phy_set_mode(struct phy *phy, enum phy_mode mode);
109 +int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
110 +#define phy_set_mode(phy, mode) \
111 + phy_set_mode_ext(phy, mode, 0)
112 +
113 static inline enum phy_mode phy_get_mode(struct phy *phy)
114 {
115 return phy->attrs.mode;
116 @@ -280,13 +283,17 @@ static inline int phy_power_off(struct p
117 return -ENOSYS;
118 }
119
120 -static inline int phy_set_mode(struct phy *phy, enum phy_mode mode)
121 +static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
122 + int submode)
123 {
124 if (!phy)
125 return 0;
126 return -ENOSYS;
127 }
128
129 +#define phy_set_mode(phy, mode) \
130 + phy_set_mode_ext(phy, mode, 0)
131 +
132 static inline enum phy_mode phy_get_mode(struct phy *phy)
133 {
134 return PHY_MODE_INVALID;