From patchwork Tue Mar 30 17:33:33 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 12173367
Return-Path:
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level:
X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,
USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
by smtp.lore.kernel.org (Postfix) with ESMTP id 60572C433DB
for ; Tue, 30 Mar 2021 17:34:19 +0000 (UTC)
Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.kernel.org (Postfix) with ESMTPS id 0021360235
for ; Tue, 30 Mar 2021 17:34:18 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0021360235
Authentication-Results: mail.kernel.org;
dmarc=fail (p=quarantine dis=none) header.from=ti.com
Authentication-Results: mail.kernel.org;
spf=none
smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding
:Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:
List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date:
Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;
bh=3CJLFVE/wtYp7kXX9ZNidy8hTyWGkNJ1u8SsgkqNrz4=; b=Iy7/mYmXg4SesbVIlhLs6AA7a
bnCgXeJf+Pc5JW+vXW/EII/2n9GWo4RKCjWgyOcd9r/YK5v7R1H6tyRFAoFQjCVUq2xShOrFZczz9
jeIr2JMUrc0+9i68VvBO7mwmOG/fV6Cjvr7QJ8+NBGPH+wz5tD7KNr9PsEfvz+WmnAGCbfaj1tCzZ
bNhjUmmdChT1V8fwC8xW9lsF5REsj61Kuz6hM2O1inOXhfDKaWn0FBXzkTI3YgoQiDcP2+NPzwcAl
Xbk5Zozpyd2ZSFZlyhhBvLvrVLkmP8Dg9yQfCfG/UG5AOfBkMszje7WrQtbCz67mMElSSUPaUzm3i
aQsJngwjw==;
Received: from localhost ([::1] helo=desiato.infradead.org)
by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux))
id 1lRIFt-004Sci-3B; Tue, 30 Mar 2021 17:34:17 +0000
Received: from fllv0015.ext.ti.com ([198.47.19.141])
by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux))
id 1lRIFm-004SbX-Qm
for linux-phy@lists.infradead.org; Tue, 30 Mar 2021 17:34:13 +0000
Received: from fllv0035.itg.ti.com ([10.64.41.0])
by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12UHY27G080685;
Tue, 30 Mar 2021 12:34:02 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1617125642;
bh=bOoAsGAFt4jk/rid5QKQyQcMiWPMKnzEbnCMJ1Uie3U=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=D7owOXb0KpBrZ0eP/FWeqeYbhDTzvBtSCRPY843Hx9WWHBn4R8/NOUb3c+Avs/l7G
7fUsk5Dm1zKqkOG53TNWrhCjXMgcCgX9DL7h2n1MxdSwaPM8HnMdc1x1s3cblH8TMt
5QkPe4UF5tnKanDaEwjCKgDMVFfqqE/KI7k4XByQ=
Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25])
by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12UHY229024850
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Tue, 30 Mar 2021 12:34:02 -0500
Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE114.ent.ti.com
(157.170.170.25) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 30
Mar 2021 12:34:02 -0500
Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE105.ent.ti.com
(157.170.170.35) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via
Frontend Transport; Tue, 30 Mar 2021 12:34:01 -0500
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12UHXmgi125244;
Tue, 30 Mar 2021 12:33:56 -0500
From: Pratyush Yadav
To: Mauro Carvalho Chehab , Rob Herring
, Kishon Vijay Abraham I , Vinod Koul
, Peter Ujfalusi ,
Maxime Ripard , Benoit Parrot ,
Hans Verkuil ,
Alexandre Courbot ,
Laurent Pinchart , Stanimir Varbanov
, Helen Koike ,
Michael Tretter ,
Peter Chen , Chunfeng Yun ,
, ,
, ,
CC: Pratyush Yadav , Vignesh Raghavendra ,
Tomi Valkeinen
Subject: [PATCH 01/16] phy: Distinguish between Rx and Tx for MIPI D-PHY with
submodes
Date: Tue, 30 Mar 2021 23:03:33 +0530
Message-ID: <20210330173348.30135-2-p.yadav@ti.com>
X-Mailer: git-send-email 2.30.0
In-Reply-To: <20210330173348.30135-1-p.yadav@ti.com>
References: <20210330173348.30135-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20210330_183411_210609_963721D4
X-CRM114-Status: GOOD ( 11.53 )
X-BeenThere: linux-phy@lists.infradead.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Linux Phy Mailing list
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Sender: "linux-phy"
Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
From: Paul Kocialkowski
As some D-PHY controllers support both Rx and Tx mode, we need a way for
users to explicitly request one or the other. For instance, Rx mode can
be used along with MIPI CSI-2 while Tx mode can be used with MIPI DSI.
Introduce new MIPI D-PHY PHY submodes to use with PHY_MODE_MIPI_DPHY.
The default (zero value) is kept to Tx so only the rkisp1 driver, which
uses D-PHY in Rx mode, needs to be adapted.
Signed-off-by: Paul Kocialkowski
Signed-off-by: Pratyush Yadav
---
include/linux/phy/phy-mipi-dphy.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/phy/phy-mipi-dphy.h b/include/linux/phy/phy-mipi-dphy.h
index a877ffee845d..0f57ef46a8b5 100644
--- a/include/linux/phy/phy-mipi-dphy.h
+++ b/include/linux/phy/phy-mipi-dphy.h
@@ -6,6 +6,19 @@
#ifndef __PHY_MIPI_DPHY_H_
#define __PHY_MIPI_DPHY_H_
+/**
+ * enum phy_mipi_dphy_submode - MIPI D-PHY sub-mode
+ *
+ * A MIPI D-PHY can be used to transmit or receive data.
+ * Since some controllers can support both, the direction to enable is specified
+ * with the PHY sub-mode. Transmit is assumed by default with phy_set_mode.
+ */
+
+enum phy_mipi_dphy_submode {
+ PHY_MIPI_DPHY_SUBMODE_TX = 0,
+ PHY_MIPI_DPHY_SUBMODE_RX,
+};
+
/**
* struct phy_configure_opts_mipi_dphy - MIPI D-PHY configuration set
*
From patchwork Tue Mar 30 17:33:34 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 12173369
Return-Path:
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level:
X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,
USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
by smtp.lore.kernel.org (Postfix) with ESMTP id 8EFAAC433C1
for ; Tue, 30 Mar 2021 17:34:22 +0000 (UTC)
Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.kernel.org (Postfix) with ESMTPS id 078F561953
for ; Tue, 30 Mar 2021 17:34:22 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 078F561953
Authentication-Results: mail.kernel.org;
dmarc=fail (p=quarantine dis=none) header.from=ti.com
Authentication-Results: mail.kernel.org;
spf=none
smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding
:Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:
List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date:
Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;
bh=8kAc85fmuXW2mMqZOu0uEdmSoSWpJhsvlAEGAX2RAX8=; b=egXB1IEK/KAnCjb+Svfmb+piA
BwnVqYkSk2IBgZmWFC/rI3syKclWaVNT5pOg5qamQ9te0GfL9NlW87NKNmVYSvc3R45TdjjJvuxxm
OwQ/6AGTSlSg1OtItARrq4FRPEptq2Wjpi1f1PPxgDfSb3UT5F0CSc4ZHdyx2gkdUFwuCftvhVflt
9j3cpXVU2MFmOECO1i0sZZqb1Jd//D+fozhmOdEUrzq5+Sa8GB6lb3TT0uy+1P80ceW7Vj/x1GmXo
AhPN3ncrIWfTnVwRw3u/fuiZ3kW3OsJpbEX7QEtK69Zl4J5pfm02RXKKhDjzMO6/Mpq4yN00ehnDJ
03WVoj05Q==;
Received: from localhost ([::1] helo=desiato.infradead.org)
by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux))
id 1lRIFw-004Sd4-6i; Tue, 30 Mar 2021 17:34:20 +0000
Received: from fllv0016.ext.ti.com ([198.47.19.142])
by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux))
id 1lRIFq-004Sc5-P1
for linux-phy@lists.infradead.org; Tue, 30 Mar 2021 17:34:17 +0000
Received: from fllv0034.itg.ti.com ([10.64.40.246])
by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12UHY80Y057005;
Tue, 30 Mar 2021 12:34:08 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1617125648;
bh=al0qmsNw4qGGrS+IvvHucR10n/i1H5Cqvddimz3Fllo=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=hRH4ppKTtspbs7IgkAuV20kiT3OtQ9wAACBZ01sx0r37zYB25zbpiFKrjtg+aZESH
qx6n6E/L9xhi4JRLVi5HXGnf7yBtrJNY3L2w23vSP/iQXfu0oztu3EFMBp9zir/5+B
k0RvzX57vE2tmhw+X5CT/UQrO8x9cyjmBcqEt4rU=
Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26])
by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12UHY8lc067690
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Tue, 30 Mar 2021 12:34:08 -0500
Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE115.ent.ti.com
(157.170.170.26) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 30
Mar 2021 12:34:08 -0500
Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE102.ent.ti.com
(157.170.170.32) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via
Frontend Transport; Tue, 30 Mar 2021 12:34:08 -0500
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12UHXmgj125244;
Tue, 30 Mar 2021 12:34:02 -0500
From: Pratyush Yadav
To: Mauro Carvalho Chehab , Rob Herring
, Kishon Vijay Abraham I , Vinod Koul
, Peter Ujfalusi ,
Maxime Ripard , Benoit Parrot ,
Hans Verkuil ,
Alexandre Courbot ,
Laurent Pinchart , Stanimir Varbanov
, Helen Koike ,
Michael Tretter ,
Peter Chen , Chunfeng Yun ,
, ,
, ,
CC: Pratyush Yadav , Vignesh Raghavendra ,
Tomi Valkeinen
Subject: [PATCH 02/16] phy: cdns-dphy: Prepare for Rx support
Date: Tue, 30 Mar 2021 23:03:34 +0530
Message-ID: <20210330173348.30135-3-p.yadav@ti.com>
X-Mailer: git-send-email 2.30.0
In-Reply-To: <20210330173348.30135-1-p.yadav@ti.com>
References: <20210330173348.30135-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20210330_183415_235974_90E61EB6
X-CRM114-Status: GOOD ( 20.52 )
X-BeenThere: linux-phy@lists.infradead.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Linux Phy Mailing list
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Sender: "linux-phy"
Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
The Rx programming sequence differs from the Tx programming sequence.
Currently only Tx mode is supported. Move all the Tx related parts into
a set of Tx-specific hooks that are then called by the main PHY
framework hooks. This way when Rx support is added all that is needed to
be done is to plug in the Rx hooks.
The clocks "psm" and "pll_ref" are not used by the Rx path so make them
optional in the probe and then check if they exist in the power_on()
hook.
Signed-off-by: Pratyush Yadav
---
drivers/phy/cadence/cdns-dphy.c | 140 ++++++++++++++++++++++++--------
1 file changed, 104 insertions(+), 36 deletions(-)
diff --git a/drivers/phy/cadence/cdns-dphy.c b/drivers/phy/cadence/cdns-dphy.c
index ba042e39cfaf..8656f2102a91 100644
--- a/drivers/phy/cadence/cdns-dphy.c
+++ b/drivers/phy/cadence/cdns-dphy.c
@@ -75,6 +75,11 @@ struct cdns_dphy;
struct cdns_dphy_ops {
int (*probe)(struct cdns_dphy *dphy);
void (*remove)(struct cdns_dphy *dphy);
+ int (*power_on)(struct cdns_dphy *dphy);
+ int (*power_off)(struct cdns_dphy *dphy);
+ int (*validate)(struct cdns_dphy *dphy, enum phy_mode mode, int submode,
+ union phy_configure_opts *opts);
+ int (*configure)(struct cdns_dphy *dphy, union phy_configure_opts *opts);
void (*set_psm_div)(struct cdns_dphy *dphy, u8 div);
void (*set_clk_lane_cfg)(struct cdns_dphy *dphy,
enum cdns_dphy_clk_lane_cfg cfg);
@@ -86,12 +91,18 @@ struct cdns_dphy_ops {
struct cdns_dphy {
struct cdns_dphy_cfg cfg;
void __iomem *regs;
+ struct device *dev;
struct clk *psm_clk;
struct clk *pll_ref_clk;
const struct cdns_dphy_ops *ops;
struct phy *phy;
};
+struct cdns_dphy_driver_data {
+ const struct cdns_dphy_ops *tx;
+ const struct cdns_dphy_ops *rx;
+};
+
static int cdns_dsi_get_dphy_pll_cfg(struct cdns_dphy *dphy,
struct cdns_dphy_cfg *cfg,
struct phy_configure_opts_mipi_dphy *opts,
@@ -199,20 +210,9 @@ static void cdns_dphy_ref_set_psm_div(struct cdns_dphy *dphy, u8 div)
dphy->regs + DPHY_PSM_CFG);
}
-/*
- * This is the reference implementation of DPHY hooks. Specific integration of
- * this IP may have to re-implement some of them depending on how they decided
- * to wire things in the SoC.
- */
-static const struct cdns_dphy_ops ref_dphy_ops = {
- .get_wakeup_time_ns = cdns_dphy_ref_get_wakeup_time_ns,
- .set_pll_cfg = cdns_dphy_ref_set_pll_cfg,
- .set_psm_div = cdns_dphy_ref_set_psm_div,
-};
-
-static int cdns_dphy_config_from_opts(struct phy *phy,
- struct phy_configure_opts_mipi_dphy *opts,
- struct cdns_dphy_cfg *cfg)
+static int cdns_dphy_tx_config_from_opts(struct phy *phy,
+ struct phy_configure_opts_mipi_dphy *opts,
+ struct cdns_dphy_cfg *cfg)
{
struct cdns_dphy *dphy = phy_get_drvdata(phy);
unsigned int dsi_hfp_ext = 0;
@@ -232,24 +232,13 @@ static int cdns_dphy_config_from_opts(struct phy *phy,
return 0;
}
-static int cdns_dphy_validate(struct phy *phy, enum phy_mode mode, int submode,
- union phy_configure_opts *opts)
+static int cdns_dphy_tx_configure(struct cdns_dphy *dphy,
+ union phy_configure_opts *opts)
{
struct cdns_dphy_cfg cfg = { 0 };
-
- if (mode != PHY_MODE_MIPI_DPHY)
- return -EINVAL;
-
- return cdns_dphy_config_from_opts(phy, &opts->mipi_dphy, &cfg);
-}
-
-static int cdns_dphy_configure(struct phy *phy, union phy_configure_opts *opts)
-{
- struct cdns_dphy *dphy = phy_get_drvdata(phy);
- struct cdns_dphy_cfg cfg = { 0 };
int ret;
- ret = cdns_dphy_config_from_opts(phy, &opts->mipi_dphy, &cfg);
+ ret = cdns_dphy_tx_config_from_opts(dphy->phy, &opts->mipi_dphy, &cfg);
if (ret)
return ret;
@@ -279,9 +268,21 @@ static int cdns_dphy_configure(struct phy *phy, union phy_configure_opts *opts)
return 0;
}
-static int cdns_dphy_power_on(struct phy *phy)
+static int cdns_dphy_tx_validate(struct cdns_dphy *dphy, enum phy_mode mode,
+ int submode, union phy_configure_opts *opts)
{
- struct cdns_dphy *dphy = phy_get_drvdata(phy);
+ struct cdns_dphy_cfg cfg = { 0 };
+
+ if (submode != PHY_MIPI_DPHY_SUBMODE_TX)
+ return -EINVAL;
+
+ return cdns_dphy_tx_config_from_opts(dphy->phy, &opts->mipi_dphy, &cfg);
+}
+
+static int cdns_dphy_tx_power_on(struct cdns_dphy *dphy)
+{
+ if (!dphy->psm_clk || !dphy->pll_ref_clk)
+ return -EINVAL;
clk_prepare_enable(dphy->psm_clk);
clk_prepare_enable(dphy->pll_ref_clk);
@@ -293,16 +294,77 @@ static int cdns_dphy_power_on(struct phy *phy)
return 0;
}
-static int cdns_dphy_power_off(struct phy *phy)
+static int cdns_dphy_tx_power_off(struct cdns_dphy *dphy)
{
- struct cdns_dphy *dphy = phy_get_drvdata(phy);
-
clk_disable_unprepare(dphy->pll_ref_clk);
clk_disable_unprepare(dphy->psm_clk);
return 0;
}
+static const struct cdns_dphy_ops tx_ref_dphy_ops = {
+ .power_on = cdns_dphy_tx_power_on,
+ .power_off = cdns_dphy_tx_power_off,
+ .validate = cdns_dphy_tx_validate,
+ .configure = cdns_dphy_tx_configure,
+ .get_wakeup_time_ns = cdns_dphy_ref_get_wakeup_time_ns,
+ .set_pll_cfg = cdns_dphy_ref_set_pll_cfg,
+ .set_psm_div = cdns_dphy_ref_set_psm_div,
+};
+
+/*
+ * This is the reference implementation of DPHY hooks. Specific integration of
+ * this IP may have to re-implement some of them depending on how they decided
+ * to wire things in the SoC.
+ */
+static const struct cdns_dphy_driver_data ref_dphy_ops = {
+ .tx = &tx_ref_dphy_ops,
+};
+
+static int cdns_dphy_validate(struct phy *phy, enum phy_mode mode, int submode,
+ union phy_configure_opts *opts)
+{
+ struct cdns_dphy *dphy = phy_get_drvdata(phy);
+
+ if (mode != PHY_MODE_MIPI_DPHY)
+ return -EINVAL;
+
+ if (dphy->ops->validate)
+ return dphy->ops->validate(dphy, mode, submode, opts);
+
+ return 0;
+}
+
+static int cdns_dphy_power_on(struct phy *phy)
+{
+ struct cdns_dphy *dphy = phy_get_drvdata(phy);
+
+ if (dphy->ops->power_on)
+ return dphy->ops->power_on(dphy);
+
+ return 0;
+}
+
+static int cdns_dphy_power_off(struct phy *phy)
+{
+ struct cdns_dphy *dphy = phy_get_drvdata(phy);
+
+ if (dphy->ops->power_off)
+ return dphy->ops->power_off(dphy);
+
+ return 0;
+}
+
+static int cdns_dphy_configure(struct phy *phy, union phy_configure_opts *opts)
+{
+ struct cdns_dphy *dphy = phy_get_drvdata(phy);
+
+ if (dphy->ops->configure)
+ return dphy->ops->configure(dphy, opts);
+
+ return 0;
+}
+
static const struct phy_ops cdns_dphy_ops = {
.configure = cdns_dphy_configure,
.validate = cdns_dphy_validate,
@@ -314,14 +376,20 @@ static int cdns_dphy_probe(struct platform_device *pdev)
{
struct phy_provider *phy_provider;
struct cdns_dphy *dphy;
+ const struct cdns_dphy_driver_data *ddata;
int ret;
dphy = devm_kzalloc(&pdev->dev, sizeof(*dphy), GFP_KERNEL);
if (!dphy)
return -ENOMEM;
dev_set_drvdata(&pdev->dev, dphy);
+ dphy->dev = &pdev->dev;
- dphy->ops = of_device_get_match_data(&pdev->dev);
+ ddata = of_device_get_match_data(&pdev->dev);
+ if (!ddata)
+ return -EINVAL;
+
+ dphy->ops = ddata->tx;
if (!dphy->ops)
return -EINVAL;
@@ -329,11 +397,11 @@ static int cdns_dphy_probe(struct platform_device *pdev)
if (IS_ERR(dphy->regs))
return PTR_ERR(dphy->regs);
- dphy->psm_clk = devm_clk_get(&pdev->dev, "psm");
+ dphy->psm_clk = devm_clk_get_optional(dphy->dev, "psm");
if (IS_ERR(dphy->psm_clk))
return PTR_ERR(dphy->psm_clk);
- dphy->pll_ref_clk = devm_clk_get(&pdev->dev, "pll_ref");
+ dphy->pll_ref_clk = devm_clk_get_optional(dphy->dev, "pll_ref");
if (IS_ERR(dphy->pll_ref_clk))
return PTR_ERR(dphy->pll_ref_clk);
From patchwork Tue Mar 30 17:33:35 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 12173371
Return-Path:
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level:
X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,
USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
by smtp.lore.kernel.org (Postfix) with ESMTP id 8D0B6C433C1
for ; Tue, 30 Mar 2021 17:34:28 +0000 (UTC)
Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.kernel.org (Postfix) with ESMTPS id 42FCD619CF
for ; Tue, 30 Mar 2021 17:34:28 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42FCD619CF
Authentication-Results: mail.kernel.org;
dmarc=fail (p=quarantine dis=none) header.from=ti.com
Authentication-Results: mail.kernel.org;
spf=none
smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding
:Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:
List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date:
Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;
bh=9gKl9BAEEAxA1N53mBBs6TmG6gNGP3/W65+1EroR2A0=; b=h0Yu5/E4MCNKP9vAeoGmBONwb
PP2z7v1WDIu19Pkx9KPyjNB/GtoVP6P5z2m/K20C256prGiWXdQ7prK9rRVF4+FeQ+LaY7Fitqpkl
8egz140mwZQn+cCD8u4R7QA5lU9tFLGMBJLaaq3JNLiL5PdNO97VGrdaO9Hd8TEbYgF3bZxbu5aPv
8fyZ3n7yCxoUTbmqwyE84QcCPqHTVaujtv4xl54CldaDM4dpI+IriUlIHsRytVTBUGUb6qssQVYbM
Pe/XZg2KlXrMEfVX0/m6U6pDqquahIt6E+dMgnt3ThKe4UqSj5EJLulgC0j2h4LMPPMFqjBGb+bDr
YFFD3/mYA==;
Received: from localhost ([::1] helo=desiato.infradead.org)
by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux))
id 1lRIG2-004Sdy-3Y; Tue, 30 Mar 2021 17:34:26 +0000
Received: from fllv0016.ext.ti.com ([198.47.19.142])
by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux))
id 1lRIFw-004Sd2-VL
for linux-phy@lists.infradead.org; Tue, 30 Mar 2021 17:34:23 +0000
Received: from lelv0266.itg.ti.com ([10.180.67.225])
by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12UHYEB8057026;
Tue, 30 Mar 2021 12:34:14 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1617125654;
bh=1pR43CdbgvQt4BcjIFxp/YBsY0FByo4R7bLIiRN2yqQ=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=IixW8RHl+OxFGXLIFDSqgn/T5bdagn3IUcv678zOw27hTEkj1CPbRVpzy+dEce+Kt
zmwOcyIyYoUCvaGu9iac+i47FuJpW2YTJAY0qVeLz6uY591y7WNzWV8kz1FBltUJVA
ovsLBjhZGJS/l1O7ZDsB/1IZNdplMwmKOuo8GOuE=
Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35])
by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12UHYEv8039233
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Tue, 30 Mar 2021 12:34:14 -0500
Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE114.ent.ti.com
(10.64.6.35) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 30
Mar 2021 12:34:14 -0500
Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE102.ent.ti.com
(10.64.6.23) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via
Frontend Transport; Tue, 30 Mar 2021 12:34:14 -0500
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12UHXmgk125244;
Tue, 30 Mar 2021 12:34:08 -0500
From: Pratyush Yadav
To: Mauro Carvalho Chehab , Rob Herring
, Kishon Vijay Abraham I , Vinod Koul
, Peter Ujfalusi ,
Maxime Ripard , Benoit Parrot ,
Hans Verkuil ,
Alexandre Courbot ,
Laurent Pinchart , Stanimir Varbanov
, Helen Koike ,
Michael Tretter ,
Peter Chen , Chunfeng Yun ,
, ,
, ,
CC: Pratyush Yadav , Vignesh Raghavendra ,
Tomi Valkeinen
Subject: [PATCH 03/16] phy: cdns-dphy: Allow setting mode
Date: Tue, 30 Mar 2021 23:03:35 +0530
Message-ID: <20210330173348.30135-4-p.yadav@ti.com>
X-Mailer: git-send-email 2.30.0
In-Reply-To: <20210330173348.30135-1-p.yadav@ti.com>
References: <20210330173348.30135-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20210330_183421_479351_A8F85A22
X-CRM114-Status: GOOD ( 12.87 )
X-BeenThere: linux-phy@lists.infradead.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Linux Phy Mailing list
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Sender: "linux-phy"
Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
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
---
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)
From patchwork Tue Mar 30 17:33:36 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 12173373
Return-Path:
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level:
X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,
USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
by smtp.lore.kernel.org (Postfix) with ESMTP id 9F943C433DB
for ; Tue, 30 Mar 2021 17:34:34 +0000 (UTC)
Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.kernel.org (Postfix) with ESMTPS id 1C315619B1
for ; Tue, 30 Mar 2021 17:34:34 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C315619B1
Authentication-Results: mail.kernel.org;
dmarc=fail (p=quarantine dis=none) header.from=ti.com
Authentication-Results: mail.kernel.org;
spf=none
smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding
:Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:
List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date:
Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;
bh=zQM6uUP6DeLhqumVWeOraK+So4ispNuSHDhSabTdXzg=; b=AwlkfP6kluxaYR+SfER5L31nI
7+nVhNedTorDb9iPbi+mURqw34V1vcn/nEIObpC5XSvHUcqy3BOzLSia/BR2EQtTwb3A+ubyPNRyK
MgBFqNVR9OMINlJgsHzgxEjAAaK2xlAssNBNhGeXf29bJTYufMa73RQotoJi6h6FFq0uveAsYLH5R
3qMwYx/tRkSKfPLIIhJpddaMLJ1fQUEjtuTCQ7hV5QJwzNj33yQpH8J2dHghNYMnslcu7+JkVBd+O
HPLCuTtRxyrosDzgdxLrWPXjpqJgAHq5t2taLIAS9IZ9LwhPjfTu0ue8n/Iayc4STCuaaBPP2AroL
DM+6Naxeg==;
Received: from localhost ([::1] helo=desiato.infradead.org)
by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux))
id 1lRIG7-004Set-LD; Tue, 30 Mar 2021 17:34:31 +0000
Received: from fllv0015.ext.ti.com ([198.47.19.141])
by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux))
id 1lRIG3-004Se0-5m
for linux-phy@lists.infradead.org; Tue, 30 Mar 2021 17:34:30 +0000
Received: from fllv0035.itg.ti.com ([10.64.41.0])
by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12UHYLdJ080764;
Tue, 30 Mar 2021 12:34:21 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1617125661;
bh=1Fypw72Nte2J+9GlPnAZdJjpruajqd+6kEaRZTmljYk=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=x9ydMyTqsRjZi8Wnj+rdsIZqBPRlhKcMhqp60ms4dcQ87g2UJEHbo/u6+EAasMk3s
qO+C4JmsSOSZFeJ0nDbOwzzanfSIgXd0bU/tO/zGKtikUEdKRFLh/mbr6Jf6RbUhDG
ObLw2Y2gZtmPx02aayaDAm5GQIoxhkTIsdqw6YG4=
Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38])
by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12UHYLhr025636
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Tue, 30 Mar 2021 12:34:21 -0500
Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE108.ent.ti.com
(157.170.170.38) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 30
Mar 2021 12:34:20 -0500
Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE113.ent.ti.com
(157.170.170.24) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via
Frontend Transport; Tue, 30 Mar 2021 12:34:20 -0500
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12UHXmgl125244;
Tue, 30 Mar 2021 12:34:15 -0500
From: Pratyush Yadav
To: Mauro Carvalho Chehab , Rob Herring
, Kishon Vijay Abraham I , Vinod Koul
, Peter Ujfalusi ,
Maxime Ripard , Benoit Parrot ,
Hans Verkuil ,
Alexandre Courbot ,
Laurent Pinchart , Stanimir Varbanov
, Helen Koike ,
Michael Tretter ,
Peter Chen , Chunfeng Yun ,
, ,
, ,
CC: Pratyush Yadav , Vignesh Raghavendra ,
Tomi Valkeinen
Subject: [PATCH 04/16] phy: cdns-dphy: Add Rx support
Date: Tue, 30 Mar 2021 23:03:36 +0530
Message-ID: <20210330173348.30135-5-p.yadav@ti.com>
X-Mailer: git-send-email 2.30.0
In-Reply-To: <20210330173348.30135-1-p.yadav@ti.com>
References: <20210330173348.30135-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20210330_183427_663717_C968EB17
X-CRM114-Status: GOOD ( 20.98 )
X-BeenThere: linux-phy@lists.infradead.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Linux Phy Mailing list
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Sender: "linux-phy"
Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
The Cadence DPHY can be used to receive image data over the CSI-2
protocol. Add support for Rx mode. The programming sequence differs from
the Tx mode so it is added as a separate set of hooks to isolate the two
paths.
The PHY is in Tx mode by default and it needs to be set in Rx mode by
setting the submode to PHY_MIPI_DPHY_SUBMODE_RX in the set_mode()
callback.
Signed-off-by: Pratyush Yadav
---
drivers/phy/cadence/cdns-dphy.c | 237 ++++++++++++++++++++++++++++++++
1 file changed, 237 insertions(+)
diff --git a/drivers/phy/cadence/cdns-dphy.c b/drivers/phy/cadence/cdns-dphy.c
index 7d5f7b333893..7bbca679e2bb 100644
--- a/drivers/phy/cadence/cdns-dphy.c
+++ b/drivers/phy/cadence/cdns-dphy.c
@@ -1,11 +1,14 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright: 2017-2018 Cadence Design Systems, Inc.
+ * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
*/
#include
+#include
#include
#include
+#include
#include
#include
#include
@@ -25,10 +28,14 @@
#define DPHY_PMA_RCLK(reg) (0x600 + (reg))
#define DPHY_PMA_RDATA(lane, reg) (0x700 + ((lane) * 0x100) + (reg))
#define DPHY_PCS(reg) (0xb00 + (reg))
+#define DPHY_ISO(reg) (0xc00 + (reg))
#define DPHY_CMN_SSM DPHY_PMA_CMN(0x20)
#define DPHY_CMN_SSM_EN BIT(0)
+#define DPHY_CMN_RX_BANDGAP_TIMER_MASK GENMASK(8, 1)
#define DPHY_CMN_TX_MODE_EN BIT(9)
+#define DPHY_CMN_RX_MODE_EN BIT(10)
+#define DPHY_CMN_RX_BANDGAP_TIMER 0x14
#define DPHY_CMN_PWM DPHY_PMA_CMN(0x40)
#define DPHY_CMN_PWM_DIV(x) ((x) << 20)
@@ -45,10 +52,27 @@
#define DPHY_CMN_OPDIV_FROM_REG BIT(6)
#define DPHY_CMN_OPDIV(x) ((x) << 7)
+#define DPHY_BAND_CFG DPHY_PCS(0x0)
+#define DPHY_BAND_CFG_LEFT_BAND GENMASK(4, 0)
+#define DPHY_BAND_CFG_RIGHT_BAND GENMASK(9, 5)
+
#define DPHY_PSM_CFG DPHY_PCS(0x4)
#define DPHY_PSM_CFG_FROM_REG BIT(0)
#define DPHY_PSM_CLK_DIV(x) ((x) << 1)
+#define DPHY_POWER_ISLAND_EN_DATA DPHY_PCS(0x8)
+#define DPHY_POWER_ISLAND_EN_DATA_VAL 0xaaaaaaaa
+#define DPHY_POWER_ISLAND_EN_CLK DPHY_PCS(0xc)
+#define DPHY_POWER_ISLAND_EN_CLK_VAL 0xaa
+
+#define DPHY_ISO_CL_CTRL_L DPHY_ISO(0x10)
+#define DPHY_ISO_DL_CTRL_L0 DPHY_ISO(0x14)
+#define DPHY_ISO_DL_CTRL_L1 DPHY_ISO(0x20)
+#define DPHY_ISO_DL_CTRL_L2 DPHY_ISO(0x30)
+#define DPHY_ISO_DL_CTRL_L3 DPHY_ISO(0x3c)
+#define DPHY_ISO_LANE_READY_BIT 0
+#define DPHY_ISO_LANE_READY_TIMEOUT_MS 100UL
+
#define DSI_HBP_FRAME_OVERHEAD 12
#define DSI_HSA_FRAME_OVERHEAD 14
#define DSI_HFP_FRAME_OVERHEAD 6
@@ -57,6 +81,9 @@
#define DSI_NULL_FRAME_OVERHEAD 6
#define DSI_EOT_PKT_SIZE 4
+#define DPHY_LANES_MIN 1
+#define DPHY_LANES_MAX 4
+
struct cdns_dphy_cfg {
u8 pll_ipdiv;
u8 pll_opdiv;
@@ -312,6 +339,214 @@ static const struct cdns_dphy_ops tx_ref_dphy_ops = {
.set_psm_div = cdns_dphy_ref_set_psm_div,
};
+static int cdns_dphy_rx_power_on(struct cdns_dphy *dphy)
+{
+ /* Start RX state machine. */
+ writel(DPHY_CMN_SSM_EN | DPHY_CMN_RX_MODE_EN |
+ FIELD_PREP(DPHY_CMN_RX_BANDGAP_TIMER_MASK,
+ DPHY_CMN_RX_BANDGAP_TIMER),
+ dphy->regs + DPHY_CMN_SSM);
+
+ return 0;
+}
+
+static int cdns_dphy_rx_power_off(struct cdns_dphy *dphy)
+{
+ writel(0, dphy->regs + DPHY_CMN_SSM);
+
+ return 0;
+}
+
+static int cdns_dphy_rx_get_band_ctrl(unsigned long hs_clk_rate)
+{
+ unsigned int rate = hs_clk_rate / 1000000UL;
+
+ if (rate < 80 || rate >= 2500)
+ return -EOPNOTSUPP;
+
+ if (rate >= 80 && rate < 100)
+ return 0;
+
+ if (rate >= 100 && rate < 120)
+ return 1;
+
+ if (rate >= 120 && rate < 160)
+ return 2;
+
+ if (rate >= 160 && rate < 200)
+ return 3;
+
+ if (rate >= 200 && rate < 240)
+ return 4;
+
+ if (rate >= 240 && rate < 280)
+ return 5;
+
+ if (rate >= 280 && rate < 320)
+ return 6;
+
+ if (rate >= 320 && rate < 360)
+ return 7;
+
+ if (rate >= 360 && rate < 400)
+ return 8;
+
+ if (rate >= 400 && rate < 480)
+ return 9;
+
+ if (rate >= 480 && rate < 560)
+ return 10;
+
+ if (rate >= 560 && rate < 640)
+ return 11;
+
+ if (rate >= 640 && rate < 720)
+ return 12;
+
+ if (rate >= 720 && rate < 800)
+ return 13;
+
+ if (rate >= 800 && rate < 880)
+ return 14;
+
+ if (rate >= 880 && rate < 1040)
+ return 15;
+
+ if (rate >= 1040 && rate < 1200)
+ return 16;
+
+ if (rate >= 1200 && rate < 1350)
+ return 17;
+
+ if (rate >= 1350 && rate < 1500)
+ return 18;
+
+ if (rate >= 1500 && rate < 1750)
+ return 19;
+
+ if (rate >= 1750 && rate < 2000)
+ return 20;
+
+ if (rate >= 2000 && rate < 2250)
+ return 21;
+
+ if (rate >= 2250 && rate < 2500)
+ return 22;
+
+ /* Unreachable. */
+ WARN(1, "Reached unreachable code.");
+ return -EINVAL;
+}
+
+static int cdns_dphy_rx_wait_for_bit(void __iomem *addr, unsigned int bit)
+{
+ u32 val;
+
+ return readl_relaxed_poll_timeout(addr, val, val & BIT(bit), 10,
+ DPHY_ISO_LANE_READY_TIMEOUT_MS * 1000);
+}
+
+static int cdns_dphy_rx_wait_lane_ready(struct cdns_dphy *dphy, int lanes)
+{
+ void __iomem *reg = dphy->regs;
+ int ret;
+
+ if (lanes < DPHY_LANES_MIN || lanes > DPHY_LANES_MAX)
+ return -EINVAL;
+
+ /* Clock lane */
+ ret = cdns_dphy_rx_wait_for_bit(reg + DPHY_ISO_CL_CTRL_L,
+ DPHY_ISO_LANE_READY_BIT);
+ if (ret)
+ return ret;
+
+ /* Data lanes. Minimum one lane is mandatory. */
+ ret = cdns_dphy_rx_wait_for_bit(reg + DPHY_ISO_DL_CTRL_L0,
+ DPHY_ISO_LANE_READY_BIT);
+ if (ret)
+ return ret;
+
+ if (lanes < 2)
+ return 0;
+
+ ret = cdns_dphy_rx_wait_for_bit(reg + DPHY_ISO_DL_CTRL_L1,
+ DPHY_ISO_LANE_READY_BIT);
+ if (ret)
+ return ret;
+
+ if (lanes < 3)
+ return 0;
+
+ ret = cdns_dphy_rx_wait_for_bit(reg + DPHY_ISO_DL_CTRL_L2,
+ DPHY_ISO_LANE_READY_BIT);
+ if (ret)
+ return ret;
+
+ if (lanes < 4)
+ return 0;
+
+ ret = cdns_dphy_rx_wait_for_bit(reg + DPHY_ISO_DL_CTRL_L3,
+ DPHY_ISO_LANE_READY_BIT);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int cdns_dphy_rx_configure(struct cdns_dphy *dphy,
+ union phy_configure_opts *opts)
+{
+ unsigned int reg;
+ int band_ctrl, ret;
+
+ band_ctrl = cdns_dphy_rx_get_band_ctrl(opts->mipi_dphy.hs_clk_rate);
+ if (band_ctrl < 0)
+ return band_ctrl;
+
+ reg = FIELD_PREP(DPHY_BAND_CFG_LEFT_BAND, band_ctrl) |
+ FIELD_PREP(DPHY_BAND_CFG_RIGHT_BAND, band_ctrl);
+ writel(reg, dphy->regs + DPHY_BAND_CFG);
+
+ /*
+ * Set the required power island phase 2 time. This is mandated by DPHY
+ * specs.
+ */
+ reg = DPHY_POWER_ISLAND_EN_DATA_VAL;
+ writel(reg, dphy->regs + DPHY_POWER_ISLAND_EN_DATA);
+ reg = DPHY_POWER_ISLAND_EN_CLK_VAL;
+ writel(reg, dphy->regs + DPHY_POWER_ISLAND_EN_CLK);
+
+ ret = cdns_dphy_rx_wait_lane_ready(dphy, opts->mipi_dphy.lanes);
+ if (ret) {
+ dev_err(dphy->dev, "DPHY wait for lane ready timeout\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static int cdns_dphy_rx_validate(struct cdns_dphy *dphy, enum phy_mode mode,
+ int submode, union phy_configure_opts *opts)
+{
+ int ret;
+
+ if (submode != PHY_MIPI_DPHY_SUBMODE_RX)
+ return -EINVAL;
+
+ ret = cdns_dphy_rx_get_band_ctrl(opts->mipi_dphy.hs_clk_rate);
+ if (ret < 0)
+ return ret;
+
+ return phy_mipi_dphy_config_validate(&opts->mipi_dphy);
+}
+
+static const struct cdns_dphy_ops rx_ref_dphy_ops = {
+ .power_on = cdns_dphy_rx_power_on,
+ .power_off = cdns_dphy_rx_power_off,
+ .configure = cdns_dphy_rx_configure,
+ .validate = cdns_dphy_rx_validate,
+};
+
/*
* This is the reference implementation of DPHY hooks. Specific integration of
* this IP may have to re-implement some of them depending on how they decided
@@ -319,6 +554,7 @@ static const struct cdns_dphy_ops tx_ref_dphy_ops = {
*/
static const struct cdns_dphy_driver_data ref_dphy_ops = {
.tx = &tx_ref_dphy_ops,
+ .rx = &rx_ref_dphy_ops,
};
static int cdns_dphy_validate(struct phy *phy, enum phy_mode mode, int submode,
@@ -483,5 +719,6 @@ static struct platform_driver cdns_dphy_platform_driver = {
module_platform_driver(cdns_dphy_platform_driver);
MODULE_AUTHOR("Maxime Ripard ");
+MODULE_AUTHOR("Pratyush Yadav ");
MODULE_DESCRIPTION("Cadence MIPI D-PHY Driver");
MODULE_LICENSE("GPL");
From patchwork Tue Mar 30 17:33:37 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 12173375
Return-Path:
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level:
X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,
USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
by smtp.lore.kernel.org (Postfix) with ESMTP id CBD00C433C1
for ; Tue, 30 Mar 2021 17:34:52 +0000 (UTC)
Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.kernel.org (Postfix) with ESMTPS id 718E8619D1
for ; Tue, 30 Mar 2021 17:34:52 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 718E8619D1
Authentication-Results: mail.kernel.org;
dmarc=fail (p=quarantine dis=none) header.from=ti.com
Authentication-Results: mail.kernel.org;
spf=none
smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding
:Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:
List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date:
Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;
bh=lhkyAQ8CrWcZYCFWVcp83l82oDd6cNpduUouaic3ae8=; b=p0T1EuzVUXxplBIiXuJn9i/ce
ZZkk+jr5bj8u1oznAIw+LWZlzRzd/ZdRKqobQCWxJXCA//lBjU/VwoSJ4GWvY2FlGd7P0MPgzw8Nd
SDlwLqiDmZhdQ+Bmyq7S3fehypwv1E1aJeviQ/ztTRfGqEUXxDG+kQhPpVnA20bUdiXg1DCrx3GVI
cW9TMaaSfJhvo+2j1p+095AL/z7kNGaT4IrBdnszf57QiSk/8n4jfHY2ZlbVNWtaMvqBQeYQgDQ4P
Z/A1TL+0MO4RjDLwLcEdwUyStrmAB4B/z9j23vYMFJsi6WboQ7GPLB2nTcDekq+Ae+HeC3EvR1QeT
wvalyiUfw==;
Received: from localhost ([::1] helo=desiato.infradead.org)
by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux))
id 1lRIGQ-004Si1-Fi; Tue, 30 Mar 2021 17:34:50 +0000
Received: from fllv0015.ext.ti.com ([198.47.19.141])
by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux))
id 1lRIG9-004SfB-BI
for linux-phy@lists.infradead.org; Tue, 30 Mar 2021 17:34:35 +0000
Received: from fllv0034.itg.ti.com ([10.64.40.246])
by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12UHYRHJ080786;
Tue, 30 Mar 2021 12:34:27 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1617125667;
bh=91KLtnJPHFYqMOAUrPZa0i0rIGtEKDKLSR7nXt3JQHE=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=MbeuqN1rE/6p/tqXTr0ZFRi4/gNOczP3JvoxYIS/uOl/ftgnzFDQNPzpcr4d9Abkm
ww5EK3AWZ9t1WzQLobJVZYVnXI77qithBVAjxPHkzXilnQIyfM76LCaSZ20WQxcSAW
QROKVELZbGEqEIzZS1CxVEd6+8yMUUHCnkQjDn0g=
Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41])
by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12UHYRmd068158
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Tue, 30 Mar 2021 12:34:27 -0500
Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE109.ent.ti.com
(157.170.170.41) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 30
Mar 2021 12:34:27 -0500
Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE110.ent.ti.com
(157.170.170.21) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via
Frontend Transport; Tue, 30 Mar 2021 12:34:27 -0500
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12UHXmgm125244;
Tue, 30 Mar 2021 12:34:21 -0500
From: Pratyush Yadav
To: Mauro Carvalho Chehab , Rob Herring
, Kishon Vijay Abraham I , Vinod Koul
, Peter Ujfalusi ,
Maxime Ripard , Benoit Parrot ,
Hans Verkuil ,
Alexandre Courbot ,
Laurent Pinchart , Stanimir Varbanov
, Helen Koike ,
Michael Tretter ,
Peter Chen , Chunfeng Yun ,
, ,
, ,
CC: Pratyush Yadav , Vignesh Raghavendra ,
Tomi Valkeinen
Subject: [PATCH 05/16] media: cadence: csi2rx: Add external DPHY support
Date: Tue, 30 Mar 2021 23:03:37 +0530
Message-ID: <20210330173348.30135-6-p.yadav@ti.com>
X-Mailer: git-send-email 2.30.0
In-Reply-To: <20210330173348.30135-1-p.yadav@ti.com>
References: <20210330173348.30135-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20210330_183433_928544_0B47E6D0
X-CRM114-Status: GOOD ( 23.82 )
X-BeenThere: linux-phy@lists.infradead.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Linux Phy Mailing list
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Sender: "linux-phy"
Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
Some platforms like TI's J721E can have the CSI2RX paired with an
external DPHY. Add support to enable and configure the DPHY using the
generic PHY framework.
Get the pixel rate and bpp from the subdev and pass them on to the DPHY
along with the number of lanes. All other settings are left to their
default values.
Signed-off-by: Pratyush Yadav
---
drivers/media/platform/cadence/cdns-csi2rx.c | 147 +++++++++++++++++--
1 file changed, 137 insertions(+), 10 deletions(-)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index c68a3eac62cd..31bd80e3f780 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -30,6 +30,12 @@
#define CSI2RX_STATIC_CFG_DLANE_MAP(llane, plane) ((plane) << (16 + (llane) * 4))
#define CSI2RX_STATIC_CFG_LANES_MASK GENMASK(11, 8)
+#define CSI2RX_DPHY_LANE_CTRL_REG 0x40
+#define CSI2RX_DPHY_CL_RST BIT(16)
+#define CSI2RX_DPHY_DL_RST(i) BIT((i) + 12)
+#define CSI2RX_DPHY_CL_EN BIT(4)
+#define CSI2RX_DPHY_DL_EN(i) BIT(i)
+
#define CSI2RX_STREAM_BASE(n) (((n) + 1) * 0x100)
#define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000)
@@ -54,6 +60,11 @@ enum csi2rx_pads {
CSI2RX_PAD_MAX,
};
+struct csi2rx_fmt {
+ u32 code;
+ u8 bpp;
+};
+
struct csi2rx_priv {
struct device *dev;
unsigned int count;
@@ -85,6 +96,52 @@ struct csi2rx_priv {
int source_pad;
};
+static const struct csi2rx_fmt formats[] = {
+ {
+ .code = MEDIA_BUS_FMT_YUYV8_2X8,
+ .bpp = 16,
+ },
+ {
+ .code = MEDIA_BUS_FMT_UYVY8_2X8,
+ .bpp = 16,
+ },
+ {
+ .code = MEDIA_BUS_FMT_YVYU8_2X8,
+ .bpp = 16,
+ },
+ {
+ .code = MEDIA_BUS_FMT_VYUY8_2X8,
+ .bpp = 16,
+ },
+};
+
+static u8 csi2rx_get_bpp(u32 code)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(formats); i++) {
+ if (formats[i].code == code)
+ return formats[i].bpp;
+ }
+
+ return 0;
+}
+
+static s64 csi2rx_get_pixel_rate(struct csi2rx_priv *csi2rx)
+{
+ struct v4l2_ctrl *ctrl;
+
+ ctrl = v4l2_ctrl_find(csi2rx->source_subdev->ctrl_handler,
+ V4L2_CID_PIXEL_RATE);
+ if (!ctrl) {
+ dev_err(csi2rx->dev, "no pixel rate control in subdev: %s\n",
+ csi2rx->source_subdev->name);
+ return -EINVAL;
+ }
+
+ return v4l2_ctrl_g_ctrl_int64(ctrl);
+}
+
static inline
struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev)
{
@@ -101,6 +158,55 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx)
writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG);
}
+static int csi2rx_configure_external_dphy(struct csi2rx_priv *csi2rx)
+{
+ union phy_configure_opts opts = { };
+ struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy;
+ struct v4l2_subdev_format sd_fmt;
+ s64 pixel_rate;
+ int ret;
+ u8 bpp;
+
+ sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+ sd_fmt.pad = 0;
+
+ ret = v4l2_subdev_call(csi2rx->source_subdev, pad, get_fmt, NULL,
+ &sd_fmt);
+ if (ret)
+ return ret;
+
+ bpp = csi2rx_get_bpp(sd_fmt.format.code);
+ if (!bpp)
+ return -EINVAL;
+
+ pixel_rate = csi2rx_get_pixel_rate(csi2rx);
+ if (pixel_rate < 0)
+ return pixel_rate;
+
+ ret = phy_mipi_dphy_get_default_config(pixel_rate, bpp,
+ csi2rx->num_lanes, cfg);
+ if (ret)
+ return ret;
+
+ ret = phy_set_mode_ext(csi2rx->dphy, PHY_MODE_MIPI_DPHY,
+ PHY_MIPI_DPHY_SUBMODE_RX);
+ if (ret)
+ return ret;
+
+ ret = phy_power_on(csi2rx->dphy);
+ if (ret)
+ return ret;
+
+ ret = phy_configure(csi2rx->dphy, &opts);
+ if (ret) {
+ /* Can't do anything if it fails. Ignore the return value. */
+ phy_power_off(csi2rx->dphy);
+ return ret;
+ }
+
+ return 0;
+}
+
static int csi2rx_start(struct csi2rx_priv *csi2rx)
{
unsigned int i;
@@ -139,6 +245,17 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
if (ret)
goto err_disable_pclk;
+ /* Enable DPHY clk and data lanes. */
+ if (csi2rx->dphy) {
+ reg = CSI2RX_DPHY_CL_EN | CSI2RX_DPHY_CL_RST;
+ for (i = 0; i < csi2rx->num_lanes; i++) {
+ reg |= CSI2RX_DPHY_DL_EN(csi2rx->lanes[i] - 1);
+ reg |= CSI2RX_DPHY_DL_RST(csi2rx->lanes[i] - 1);
+ }
+
+ writel(reg, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);
+ }
+
/*
* Create a static mapping between the CSI virtual channels
* and the output stream.
@@ -169,10 +286,21 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
if (ret)
goto err_disable_pixclk;
+ if (csi2rx->dphy) {
+ ret = csi2rx_configure_external_dphy(csi2rx);
+ if (ret) {
+ dev_err(csi2rx->dev,
+ "Failed to configure external DPHY: %d\n", ret);
+ goto err_disable_sysclk;
+ }
+ }
+
clk_disable_unprepare(csi2rx->p_clk);
return 0;
+err_disable_sysclk:
+ clk_disable_unprepare(csi2rx->sys_clk);
err_disable_pixclk:
for (; i > 0; i--)
clk_disable_unprepare(csi2rx->pixel_clk[i - 1]);
@@ -200,6 +328,13 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))
dev_warn(csi2rx->dev, "Couldn't disable our subdev\n");
+
+ if (csi2rx->dphy) {
+ writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);
+
+ if (phy_power_off(csi2rx->dphy))
+ dev_warn(csi2rx->dev, "Couldn't power off DPHY\n");
+ }
}
static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable)
@@ -306,15 +441,6 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
return PTR_ERR(csi2rx->dphy);
}
- /*
- * FIXME: Once we'll have external D-PHY support, the check
- * will need to be removed.
- */
- if (csi2rx->dphy) {
- dev_err(&pdev->dev, "External D-PHY not supported yet\n");
- return -EINVAL;
- }
-
clk_prepare_enable(csi2rx->p_clk);
dev_cfg = readl(csi2rx->base + CSI2RX_DEVICE_CFG_REG);
clk_disable_unprepare(csi2rx->p_clk);
@@ -339,7 +465,7 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
* FIXME: Once we'll have internal D-PHY support, the check
* will need to be removed.
*/
- if (csi2rx->has_internal_dphy) {
+ if (!csi2rx->dphy && csi2rx->has_internal_dphy) {
dev_err(&pdev->dev, "Internal D-PHY not supported yet\n");
return -EINVAL;
}
@@ -460,6 +586,7 @@ static int csi2rx_probe(struct platform_device *pdev)
dev_info(&pdev->dev,
"Probed CSI2RX with %u/%u lanes, %u streams, %s D-PHY\n",
csi2rx->num_lanes, csi2rx->max_lanes, csi2rx->max_streams,
+ csi2rx->dphy ? "external" :
csi2rx->has_internal_dphy ? "internal" : "no");
return 0;
From patchwork Tue Mar 30 17:33:38 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 12173377
Return-Path:
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level:
X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,
USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
by smtp.lore.kernel.org (Postfix) with ESMTP id DC9CEC433E1
for ; Tue, 30 Mar 2021 17:34:53 +0000 (UTC)
Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.kernel.org (Postfix) with ESMTPS id 7876A619B1
for ; Tue, 30 Mar 2021 17:34:53 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7876A619B1
Authentication-Results: mail.kernel.org;
dmarc=fail (p=quarantine dis=none) header.from=ti.com
Authentication-Results: mail.kernel.org;
spf=none
smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding
:Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:
List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date:
Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;
bh=PilBK6EbBQ+Nlw4IFnRMNZwWe9+/598ajjzcieMecRM=; b=gja/ZT7L8AV8JRShaCZJSXwbE
DlnsxYWuo++Lr95hroULvZj4sYVBQNATLH6j0irKuq6i8pul/uqbfI98XkEQ9sh24GA6u2m7N1LIH
czeDe7IUspA5zsUTB5+Ote45NKMeXGmMFYNpVY+Q4mrerKLHi0uBXOpa5ss+nJ484eQH7Y90+0Wf6
XLLhmapSYH8VpWt0T7T6r9nRyYpeTUBIig0M33trt17G4KLqvw2QltX15frbmBY/Eju4mpZfL/51P
C4+04r+3U5AC7PBdbcXIJH4tgA+rxMHINCuQbGXmujGO4bnjMAxrwGP7FvePg19AjBeAgzmWSeSIU
daU4tnHzg==;
Received: from localhost ([::1] helo=desiato.infradead.org)
by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux))
id 1lRIGR-004SiG-G3; Tue, 30 Mar 2021 17:34:51 +0000
Received: from fllv0015.ext.ti.com ([198.47.19.141])
by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux))
id 1lRIGG-004SgR-Fr
for linux-phy@lists.infradead.org; Tue, 30 Mar 2021 17:34:44 +0000
Received: from fllv0035.itg.ti.com ([10.64.41.0])
by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12UHYYdR080831;
Tue, 30 Mar 2021 12:34:34 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1617125674;
bh=e0p31IW0rH6YdPTwIarvDVW5qoY2qL7bTzo3pAqOwkc=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=CetWVJkiPzgFFaHLdUSCdCvyAAgQ8CWmMvx3M/Tqq9z9JIQr+Uomq32d727kSTaKS
goiAU23mNqq1EBPmtcg7PTbQtLvd1Fptxq28mRLVYQ3VgjQj/jcvlg+lkbwI3XaFdS
XpkWeaqJp93g9uqvhQ3eBDgYRk2DkoL8YY1I5lf0=
Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35])
by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12UHYXA5025861
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Tue, 30 Mar 2021 12:34:33 -0500
Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE105.ent.ti.com
(157.170.170.35) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 30
Mar 2021 12:34:33 -0500
Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE102.ent.ti.com
(157.170.170.32) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via
Frontend Transport; Tue, 30 Mar 2021 12:34:33 -0500
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12UHXmgn125244;
Tue, 30 Mar 2021 12:34:27 -0500
From: Pratyush Yadav
To: Mauro Carvalho Chehab , Rob Herring
, Kishon Vijay Abraham I , Vinod Koul
, Peter Ujfalusi ,
Maxime Ripard , Benoit Parrot ,
Hans Verkuil ,
Alexandre Courbot ,
Laurent Pinchart , Stanimir Varbanov
, Helen Koike ,
Michael Tretter ,
Peter Chen , Chunfeng Yun ,
, ,
, ,
CC: Pratyush Yadav , Vignesh Raghavendra ,
Tomi Valkeinen
Subject: [PATCH 06/16] media: cadence: csi2rx: Soft reset the streams before
starting capture
Date: Tue, 30 Mar 2021 23:03:38 +0530
Message-ID: <20210330173348.30135-7-p.yadav@ti.com>
X-Mailer: git-send-email 2.30.0
In-Reply-To: <20210330173348.30135-1-p.yadav@ti.com>
References: <20210330173348.30135-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20210330_183441_222117_25134709
X-CRM114-Status: GOOD ( 12.04 )
X-BeenThere: linux-phy@lists.infradead.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Linux Phy Mailing list
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Sender: "linux-phy"
Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
This resets the stream state machines and FIFOs, giving them a clean
slate. On J721E if the streams are not reset before starting the
capture, the captured frame gets wrapped around vertically on every run
after the first.
Signed-off-by: Pratyush Yadav
---
drivers/media/platform/cadence/cdns-csi2rx.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 31bd80e3f780..b03d2d2e6762 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -39,6 +39,7 @@
#define CSI2RX_STREAM_BASE(n) (((n) + 1) * 0x100)
#define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000)
+#define CSI2RX_STREAM_CTRL_SOFT_RST BIT(4)
#define CSI2RX_STREAM_CTRL_START BIT(0)
#define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008)
@@ -150,12 +151,22 @@ struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev)
static void csi2rx_reset(struct csi2rx_priv *csi2rx)
{
+ int i;
+
writel(CSI2RX_SOFT_RESET_PROTOCOL | CSI2RX_SOFT_RESET_FRONT,
csi2rx->base + CSI2RX_SOFT_RESET_REG);
udelay(10);
writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG);
+
+ /* Reset individual streams. */
+ for (i = 0; i < csi2rx->max_streams; i++) {
+ writel(CSI2RX_STREAM_CTRL_SOFT_RST,
+ csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
+ usleep_range(10, 20);
+ writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
+ }
}
static int csi2rx_configure_external_dphy(struct csi2rx_priv *csi2rx)
From patchwork Tue Mar 30 17:33:39 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 12173379
Return-Path:
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level:
X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,
USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
by smtp.lore.kernel.org (Postfix) with ESMTP id F2BA8C433DB
for ; Tue, 30 Mar 2021 17:34:56 +0000 (UTC)
Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.kernel.org (Postfix) with ESMTPS id 87E0461953
for ; Tue, 30 Mar 2021 17:34:56 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87E0461953
Authentication-Results: mail.kernel.org;
dmarc=fail (p=quarantine dis=none) header.from=ti.com
Authentication-Results: mail.kernel.org;
spf=none
smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding
:Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:
List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date:
Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;
bh=2m83flIp8l09Gljm56pQBUHhuz3XRHzideA9Js4o+w8=; b=XzLIZdQD3cZ6ZAs51oZmBbcMv
YBjiXXzgbTSz6hIqkQ6dMeDWqPxTy99Q3N4oZnDZCMhuYSLFR3+JTVgnmTk04TYwhio6Oeua2Hb1t
3PlXs7LAoHuGaUZDPpqyX8XAmH0w4w+M60CEYx8jBPPI82rJhw3HWuI1F3IS/pcRhlWj4PpqD+XTv
VGOJ7ajljmGAafNQPirYlQCbbxnvORVMOUeXbchuBAt4BG49puxTbELiPqHhmL8GQs6kQhBnuGFpd
4HIJcpM0NA5a+ouwgqsvcn+vH6iBHKq3K9RRo61HLuWS0c0nhf5RbMKG9HQoj9VkTz6S8m6AYKPcd
0S1NrZA+g==;
Received: from localhost ([::1] helo=desiato.infradead.org)
by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux))
id 1lRIGS-004Sib-Jl; Tue, 30 Mar 2021 17:34:54 +0000
Received: from fllv0016.ext.ti.com ([198.47.19.142])
by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux))
id 1lRIGM-004ShE-B9
for linux-phy@lists.infradead.org; Tue, 30 Mar 2021 17:34:50 +0000
Received: from lelv0265.itg.ti.com ([10.180.67.224])
by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12UHYeRx057154;
Tue, 30 Mar 2021 12:34:40 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1617125680;
bh=WJ3Cx3ofV6De0Wuahc0WcN8cdQ6M4oqLHfm471L5vg8=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=RPzxkrpZM0foWXsT7PzPKgRAhl4nlfh0vdvQm8oMZvXc3Ieh5UnmdphsDAQBOl9hE
983P4xPjXFgcaR+cFoZZur5yzfRmRFkHGwmSzxW+v8aS4Kpb4+SA6FsMU8ajiRWeEX
41HGmgHgohQ29BHSk1NbiSGOkLsk68+kL0Z8jDu8=
Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21])
by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12UHYe23032597
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Tue, 30 Mar 2021 12:34:40 -0500
Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE100.ent.ti.com
(10.64.6.21) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 30
Mar 2021 12:34:39 -0500
Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE110.ent.ti.com
(10.64.6.31) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via
Frontend Transport; Tue, 30 Mar 2021 12:34:39 -0500
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12UHXmgo125244;
Tue, 30 Mar 2021 12:34:34 -0500
From: Pratyush Yadav
To: Mauro Carvalho Chehab , Rob Herring
, Kishon Vijay Abraham I , Vinod Koul
, Peter Ujfalusi ,
Maxime Ripard , Benoit Parrot ,
Hans Verkuil ,
Alexandre Courbot ,
Laurent Pinchart , Stanimir Varbanov
, Helen Koike ,
Michael Tretter ,
Peter Chen , Chunfeng Yun