linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pratyush Yadav <p.yadav@ti.com>
To: Vinod Koul <vkoul@kernel.org>
Cc: Nikhil Devshatwar <nikhil.nd@ti.com>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Pratyush Yadav <p.yadav@ti.com>,
	Chunfeng Yun <chunfeng.yun@mediatek.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Peter Chen <peter.chen@nxp.com>, <linux-kernel@vger.kernel.org>,
	<linux-phy@lists.infradead.org>
Subject: [PATCH v3 3/7] phy: cdns-dphy: Allow setting mode
Date: Fri, 25 Jun 2021 00:11:04 +0530	[thread overview]
Message-ID: <20210624184108.21312-4-p.yadav@ti.com> (raw)
In-Reply-To: <20210624184108.21312-1-p.yadav@ti.com>

Allow callers to set the PHY mode. The main mode should always be
PHY_MODE_MIPI_DPHY but the submode can either be
PHY_MIPI_DPHY_SUBMODE_RX or PHY_MIPI_DPHY_SUBMODE_TX. Update the ops
based on the requested submode.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
---

(no changes since v1)

 drivers/phy/cadence/cdns-dphy.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/phy/cadence/cdns-dphy.c b/drivers/phy/cadence/cdns-dphy.c
index 8656f2102a91..7d5f7b333893 100644
--- a/drivers/phy/cadence/cdns-dphy.c
+++ b/drivers/phy/cadence/cdns-dphy.c
@@ -365,11 +365,41 @@ static int cdns_dphy_configure(struct phy *phy, union phy_configure_opts *opts)
 	return 0;
 }
 
+static int cdns_dphy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
+{
+	struct cdns_dphy *dphy = phy_get_drvdata(phy);
+	const struct cdns_dphy_driver_data *ddata;
+
+	ddata = of_device_get_match_data(dphy->dev);
+	if (!ddata)
+		return -EINVAL;
+
+	if (mode != PHY_MODE_MIPI_DPHY)
+		return -EINVAL;
+
+	if (submode == PHY_MIPI_DPHY_SUBMODE_TX) {
+		if (!ddata->tx)
+			return -EOPNOTSUPP;
+
+		dphy->ops = ddata->tx;
+	} else if (submode == PHY_MIPI_DPHY_SUBMODE_RX) {
+		if (!ddata->rx)
+			return -EOPNOTSUPP;
+
+		dphy->ops = ddata->rx;
+	} else {
+		return -EOPNOTSUPP;
+	}
+
+	return 0;
+}
+
 static const struct phy_ops cdns_dphy_ops = {
 	.configure	= cdns_dphy_configure,
 	.validate	= cdns_dphy_validate,
 	.power_on	= cdns_dphy_power_on,
 	.power_off	= cdns_dphy_power_off,
+	.set_mode	= cdns_dphy_set_mode,
 };
 
 static int cdns_dphy_probe(struct platform_device *pdev)
-- 
2.30.0


  parent reply	other threads:[~2021-06-24 18:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24 18:41 [PATCH v3 0/7] Rx mode support for Cadence DPHY Pratyush Yadav
2021-06-24 18:41 ` [PATCH v3 1/7] phy: Distinguish between Rx and Tx for MIPI D-PHY with submodes Pratyush Yadav
2021-08-06 11:11   ` Paul Kocialkowski
2021-08-11 17:36     ` Pratyush Yadav
2021-06-24 18:41 ` [PATCH v3 2/7] phy: cdns-dphy: Prepare for Rx support Pratyush Yadav
2021-08-06 10:18   ` Vinod Koul
2021-08-11 17:39     ` Pratyush Yadav
2021-06-24 18:41 ` Pratyush Yadav [this message]
2021-06-24 18:41 ` [PATCH v3 4/7] phy: cdns-dphy: Add " Pratyush Yadav
2021-08-06 11:15   ` Vinod Koul
2021-08-11 17:33     ` Pratyush Yadav
2021-06-24 18:41 ` [PATCH v3 5/7] phy: dt-bindings: Convert Cadence DPHY binding to YAML Pratyush Yadav
2021-06-24 18:41 ` [PATCH v3 6/7] phy: dt-bindings: cdns,dphy: make clocks optional Pratyush Yadav
2021-06-24 18:41 ` [PATCH v3 7/7] phy: dt-bindings: cdns,dphy: add power-domains property Pratyush Yadav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210624184108.21312-4-p.yadav@ti.com \
    --to=p.yadav@ti.com \
    --cc=chunfeng.yun@mediatek.com \
    --cc=kishon@ti.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=nikhil.nd@ti.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=peter.chen@nxp.com \
    --cc=tomi.valkeinen@ideasonboard.com \
    --cc=vigneshr@ti.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).