Commit 79a5a18a authored by Grygorii Strashko's avatar Grygorii Strashko Committed by Kishon Vijay Abraham I
Browse files

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: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent 640ac147
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -478,7 +478,8 @@ static int sun4i_usb_phy_power_off(struct phy *_phy)
	return 0;
}

static int sun4i_usb_phy_set_mode(struct phy *_phy, enum phy_mode mode)
static int sun4i_usb_phy_set_mode(struct phy *_phy,
				  enum phy_mode mode, int submode)
{
	struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
	struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);
+3 −2
Original line number Diff line number Diff line
@@ -152,7 +152,8 @@ static int phy_meson_gxl_usb2_reset(struct phy *phy)
	return 0;
}

static int phy_meson_gxl_usb2_set_mode(struct phy *phy, enum phy_mode mode)
static int phy_meson_gxl_usb2_set_mode(struct phy *phy,
				       enum phy_mode mode, int submode)
{
	struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy);

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

	ret = phy_meson_gxl_usb2_set_mode(phy, priv->mode);
	ret = phy_meson_gxl_usb2_set_mode(phy, priv->mode, 0);
	if (ret) {
		phy_meson_gxl_usb2_power_off(phy);

+3 −2
Original line number Diff line number Diff line
@@ -119,7 +119,8 @@ static int phy_meson_gxl_usb3_power_off(struct phy *phy)
	return 0;
}

static int phy_meson_gxl_usb3_set_mode(struct phy *phy, enum phy_mode mode)
static int phy_meson_gxl_usb3_set_mode(struct phy *phy,
				       enum phy_mode mode, int submode)
{
	struct phy_meson_gxl_usb3_priv *priv = phy_get_drvdata(phy);

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

	ret = phy_meson_gxl_usb3_set_mode(phy, priv->mode);
	ret = phy_meson_gxl_usb3_set_mode(phy, priv->mode, 0);
	if (ret)
		goto err_disable_clk_peripheral;

+2 −1
Original line number Diff line number Diff line
@@ -512,7 +512,8 @@ static int mvebu_comphy_power_on(struct phy *phy)
	return ret;
}

static int mvebu_comphy_set_mode(struct phy *phy, enum phy_mode mode)
static int mvebu_comphy_set_mode(struct phy *phy,
				 enum phy_mode mode, int submode)
{
	struct mvebu_comphy_lane *lane = phy_get_drvdata(phy);

+1 −1
Original line number Diff line number Diff line
@@ -971,7 +971,7 @@ static int mtk_phy_exit(struct phy *phy)
	return 0;
}

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