Commit 9f5f6083 authored by Xiangxu Yin's avatar Xiangxu Yin Committed by Vinod Koul
Browse files

phy: qcom: qmp-usbc: Rename USB-specific ops to prepare for DP support



To support following DisplayPort (DP) mode over the Type-C PHY, rename
USB-specific functions and ops to clearly separate them from common or
DP-related logic.

This is a preparatory cleanup to enable USB + DP dual mode.

Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: default avatarXiangxu Yin <xiangxu.yin@oss.qualcomm.com>
Link: https://patch.msgid.link/20251215-add-displayport-support-for-qcs615-platform-v8-2-cbc72c88a44e@oss.qualcomm.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 70f12a4c
Loading
Loading
Loading
Loading
+27 −28
Original line number Diff line number Diff line
@@ -342,11 +342,10 @@ struct qmp_usbc {

	struct mutex phy_mutex;

	struct phy *usb_phy;
	enum phy_mode mode;
	unsigned int usb_init_count;

	struct phy *phy;

	struct clk_fixed_rate pipe_clk_fixed;

	struct typec_switch_dev *sw;
@@ -454,7 +453,7 @@ static const struct qmp_phy_cfg sdm660_usb3phy_cfg = {
	.regs			= qmp_v3_usb3phy_regs_layout_qcm2290,
};

static int qmp_usbc_init(struct phy *phy)
static int qmp_usbc_com_init(struct phy *phy)
{
	struct qmp_usbc *qmp = phy_get_drvdata(phy);
	const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -504,7 +503,7 @@ static int qmp_usbc_init(struct phy *phy)
	return ret;
}

static int qmp_usbc_exit(struct phy *phy)
static int qmp_usbc_com_exit(struct phy *phy)
{
	struct qmp_usbc *qmp = phy_get_drvdata(phy);
	const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -518,7 +517,7 @@ static int qmp_usbc_exit(struct phy *phy)
	return 0;
}

static int qmp_usbc_power_on(struct phy *phy)
static int qmp_usbc_usb_power_on(struct phy *phy)
{
	struct qmp_usbc *qmp = phy_get_drvdata(phy);
	const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -566,7 +565,7 @@ static int qmp_usbc_power_on(struct phy *phy)
	return ret;
}

static int qmp_usbc_power_off(struct phy *phy)
static int qmp_usbc_usb_power_off(struct phy *phy)
{
	struct qmp_usbc *qmp = phy_get_drvdata(phy);
	const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -587,20 +586,20 @@ static int qmp_usbc_power_off(struct phy *phy)
	return 0;
}

static int qmp_usbc_enable(struct phy *phy)
static int qmp_usbc_usb_enable(struct phy *phy)
{
	struct qmp_usbc *qmp = phy_get_drvdata(phy);
	int ret;

	mutex_lock(&qmp->phy_mutex);

	ret = qmp_usbc_init(phy);
	ret = qmp_usbc_com_init(phy);
	if (ret)
		goto out_unlock;

	ret = qmp_usbc_power_on(phy);
	ret = qmp_usbc_usb_power_on(phy);
	if (ret) {
		qmp_usbc_exit(phy);
		qmp_usbc_com_exit(phy);
		goto out_unlock;
	}

@@ -611,19 +610,19 @@ static int qmp_usbc_enable(struct phy *phy)
	return ret;
}

static int qmp_usbc_disable(struct phy *phy)
static int qmp_usbc_usb_disable(struct phy *phy)
{
	struct qmp_usbc *qmp = phy_get_drvdata(phy);
	int ret;

	qmp->usb_init_count--;
	ret = qmp_usbc_power_off(phy);
	ret = qmp_usbc_usb_power_off(phy);
	if (ret)
		return ret;
	return qmp_usbc_exit(phy);
	return qmp_usbc_com_exit(phy);
}

static int qmp_usbc_set_mode(struct phy *phy, enum phy_mode mode, int submode)
static int qmp_usbc_usb_set_mode(struct phy *phy, enum phy_mode mode, int submode)
{
	struct qmp_usbc *qmp = phy_get_drvdata(phy);

@@ -632,10 +631,10 @@ static int qmp_usbc_set_mode(struct phy *phy, enum phy_mode mode, int submode)
	return 0;
}

static const struct phy_ops qmp_usbc_phy_ops = {
	.init		= qmp_usbc_enable,
	.exit		= qmp_usbc_disable,
	.set_mode	= qmp_usbc_set_mode,
static const struct phy_ops qmp_usbc_usb_phy_ops = {
	.init		= qmp_usbc_usb_enable,
	.exit		= qmp_usbc_usb_disable,
	.set_mode	= qmp_usbc_usb_set_mode,
	.owner		= THIS_MODULE,
};

@@ -690,7 +689,7 @@ static int __maybe_unused qmp_usbc_runtime_suspend(struct device *dev)

	dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->mode);

	if (!qmp->phy->init_count) {
	if (!qmp->usb_init_count) {
		dev_vdbg(dev, "PHY not initialized, bailing out\n");
		return 0;
	}
@@ -710,7 +709,7 @@ static int __maybe_unused qmp_usbc_runtime_resume(struct device *dev)

	dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->mode);

	if (!qmp->phy->init_count) {
	if (!qmp->usb_init_count) {
		dev_vdbg(dev, "PHY not initialized, bailing out\n");
		return 0;
	}
@@ -865,11 +864,11 @@ static int qmp_usbc_typec_switch_set(struct typec_switch_dev *sw,
	qmp->orientation = orientation;

	if (qmp->usb_init_count) {
		qmp_usbc_power_off(qmp->phy);
		qmp_usbc_exit(qmp->phy);
		qmp_usbc_usb_power_off(qmp->usb_phy);
		qmp_usbc_com_exit(qmp->usb_phy);

		qmp_usbc_init(qmp->phy);
		qmp_usbc_power_on(qmp->phy);
		qmp_usbc_com_init(qmp->usb_phy);
		qmp_usbc_usb_power_on(qmp->usb_phy);
	}

	mutex_unlock(&qmp->phy_mutex);
@@ -1097,14 +1096,14 @@ static int qmp_usbc_probe(struct platform_device *pdev)
	if (ret)
		goto err_node_put;

	qmp->phy = devm_phy_create(dev, np, &qmp_usbc_phy_ops);
	if (IS_ERR(qmp->phy)) {
		ret = PTR_ERR(qmp->phy);
	qmp->usb_phy = devm_phy_create(dev, np, &qmp_usbc_usb_phy_ops);
	if (IS_ERR(qmp->usb_phy)) {
		ret = PTR_ERR(qmp->usb_phy);
		dev_err(dev, "failed to create PHY: %d\n", ret);
		goto err_node_put;
	}

	phy_set_drvdata(qmp->phy, qmp);
	phy_set_drvdata(qmp->usb_phy, qmp);

	of_node_put(np);