Skip to content

Commit 79a5a18

Browse files
grygoriySkishon
authored andcommitted
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>
1 parent 640ac14 commit 79a5a18

16 files changed

Lines changed: 39 additions & 22 deletions

‎drivers/phy/allwinner/phy-sun4i-usb.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ static int sun4i_usb_phy_power_off(struct phy *_phy)
478478
return 0;
479479
}
480480

481-
static int sun4i_usb_phy_set_mode(struct phy *_phy, enum phy_mode mode)
481+
static int sun4i_usb_phy_set_mode(struct phy *_phy,
482+
enum phy_mode mode, int submode)
482483
{
483484
struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
484485
struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);

‎drivers/phy/amlogic/phy-meson-gxl-usb2.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ static int phy_meson_gxl_usb2_reset(struct phy *phy)
152152
return 0;
153153
}
154154

155-
static int phy_meson_gxl_usb2_set_mode(struct phy *phy, enum phy_mode mode)
155+
static int phy_meson_gxl_usb2_set_mode(struct phy *phy,
156+
enum phy_mode mode, int submode)
156157
{
157158
struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy);
158159

@@ -209,7 +210,7 @@ static int phy_meson_gxl_usb2_power_on(struct phy *phy)
209210
/* power on the PHY by taking it out of reset mode */
210211
regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_POWER_ON_RESET, 0);
211212

212-
ret = phy_meson_gxl_usb2_set_mode(phy, priv->mode);
213+
ret = phy_meson_gxl_usb2_set_mode(phy, priv->mode, 0);
213214
if (ret) {
214215
phy_meson_gxl_usb2_power_off(phy);
215216

‎drivers/phy/amlogic/phy-meson-gxl-usb3.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ static int phy_meson_gxl_usb3_power_off(struct phy *phy)
119119
return 0;
120120
}
121121

122-
static int phy_meson_gxl_usb3_set_mode(struct phy *phy, enum phy_mode mode)
122+
static int phy_meson_gxl_usb3_set_mode(struct phy *phy,
123+
enum phy_mode mode, int submode)
123124
{
124125
struct phy_meson_gxl_usb3_priv *priv = phy_get_drvdata(phy);
125126

@@ -164,7 +165,7 @@ static int phy_meson_gxl_usb3_init(struct phy *phy)
164165
if (ret)
165166
goto err_disable_clk_phy;
166167

167-
ret = phy_meson_gxl_usb3_set_mode(phy, priv->mode);
168+
ret = phy_meson_gxl_usb3_set_mode(phy, priv->mode, 0);
168169
if (ret)
169170
goto err_disable_clk_peripheral;
170171

‎drivers/phy/marvell/phy-mvebu-cp110-comphy.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ static int mvebu_comphy_power_on(struct phy *phy)
512512
return ret;
513513
}
514514

515-
static int mvebu_comphy_set_mode(struct phy *phy, enum phy_mode mode)
515+
static int mvebu_comphy_set_mode(struct phy *phy,
516+
enum phy_mode mode, int submode)
516517
{
517518
struct mvebu_comphy_lane *lane = phy_get_drvdata(phy);
518519

‎drivers/phy/mediatek/phy-mtk-tphy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ static int mtk_phy_exit(struct phy *phy)
971971
return 0;
972972
}
973973

974-
static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode)
974+
static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
975975
{
976976
struct mtk_phy_instance *instance = phy_get_drvdata(phy);
977977
struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent);

‎drivers/phy/mediatek/phy-mtk-xsphy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ static int mtk_phy_exit(struct phy *phy)
426426
return 0;
427427
}
428428

429-
static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode)
429+
static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
430430
{
431431
struct xsphy_instance *inst = phy_get_drvdata(phy);
432432
struct mtk_xsphy *xsphy = dev_get_drvdata(phy->dev.parent);

‎drivers/phy/mscc/phy-ocelot-serdes.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static const struct serdes_mux ocelot_serdes_muxes[] = {
158158
HSIO_HW_CFG_PCIE_ENA),
159159
};
160160

161-
static int serdes_set_mode(struct phy *phy, enum phy_mode mode)
161+
static int serdes_set_mode(struct phy *phy, enum phy_mode mode, int submode)
162162
{
163163
struct serdes_macro *macro = phy_get_drvdata(phy);
164164
unsigned int i;

‎drivers/phy/phy-core.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,22 +360,22 @@ int phy_power_off(struct phy *phy)
360360
}
361361
EXPORT_SYMBOL_GPL(phy_power_off);
362362

363-
int phy_set_mode(struct phy *phy, enum phy_mode mode)
363+
int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode)
364364
{
365365
int ret;
366366

367367
if (!phy || !phy->ops->set_mode)
368368
return 0;
369369

370370
mutex_lock(&phy->mutex);
371-
ret = phy->ops->set_mode(phy, mode);
371+
ret = phy->ops->set_mode(phy, mode, submode);
372372
if (!ret)
373373
phy->attrs.mode = mode;
374374
mutex_unlock(&phy->mutex);
375375

376376
return ret;
377377
}
378-
EXPORT_SYMBOL_GPL(phy_set_mode);
378+
EXPORT_SYMBOL_GPL(phy_set_mode_ext);
379379

380380
int phy_reset(struct phy *phy)
381381
{

‎drivers/phy/qualcomm/phy-qcom-qmp.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,8 @@ static int qcom_qmp_phy_poweron(struct phy *phy)
13651365
return ret;
13661366
}
13671367

1368-
static int qcom_qmp_phy_set_mode(struct phy *phy, enum phy_mode mode)
1368+
static int qcom_qmp_phy_set_mode(struct phy *phy,
1369+
enum phy_mode mode, int submode)
13691370
{
13701371
struct qmp_phy *qphy = phy_get_drvdata(phy);
13711372
struct qcom_qmp *qmp = qphy->qmp;

‎drivers/phy/qualcomm/phy-qcom-qusb2.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ static void qusb2_phy_set_tune2_param(struct qusb2_phy *qphy)
425425
HSTX_TRIM_MASK);
426426
}
427427

428-
static int qusb2_phy_set_mode(struct phy *phy, enum phy_mode mode)
428+
static int qusb2_phy_set_mode(struct phy *phy,
429+
enum phy_mode mode, int submode)
429430
{
430431
struct qusb2_phy *qphy = phy_get_drvdata(phy);
431432

0 commit comments

Comments
 (0)