From patchwork Fri Aug 11 10:47:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 13350582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10BC7C001B0 for ; Fri, 11 Aug 2023 10:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=dRqQD1lnsSUbEpLSt9RZsa15SD5G/6a3fFUITBeS3c0=; b=uoRX3V0PWnpCAq oCAkJOm1CBLAAajAnHYikjNtdN4jgcb6MaAF+L0ALQZutpA9XJxh12c/NtwhTZ7unh0KY0v9x4mIc IWxMtfh0ThtN2Tz+qfegOguubLQCrGcncHhugbJqkmzZqOfzCFkDmgSXVemAQaU+ofGOeD4ZrJOpL 6CyxxQw/P92xIxN/v9IMKDYaPRhv0hasGzPIT4eLcdldJc/93ZjivchH9zJtjrgMoGe1jdV04yzwj WJWqUR2TWlnvPXUYgb3Lh2LIuceCfC0mMRoboFjqhLnAYVvAqVRswTkXrC3lBbEBm84lsMb0jGgdO MxEfTTCuNyiQCKbJ9tng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qUPhg-00AKm3-2g; Fri, 11 Aug 2023 10:49:12 +0000 Received: from lelv0143.ext.ti.com ([198.47.23.248]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qUPhA-00AKQ1-1F for linux-arm-kernel@lists.infradead.org; Fri, 11 Aug 2023 10:48:43 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 37BAlnJN014080; Fri, 11 Aug 2023 05:47:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1691750869; bh=cYwOg9sSDDYs3eB9PIp6KRE5y9IJWBUenEYnEjKg6d4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=sULh9hgDkYbpveexEOVVPCzzWKfjsI8l4oyi7CRKIrThHTLo2XfbqIZeVIRRwyCkm 0kecPhd+CxXAfQodm7kbb2BUMXw2WiYXwmKhfoGQLbrgjNrMFy6kbXbHZ6hH2fMBSZ 53gie7LyLCM1YE6xPkaHWwl9b8Z/xZva62uxWEfc= 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 37BAlnwB041933 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 11 Aug 2023 05:47:49 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) 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.2507.23; Fri, 11 Aug 2023 05:47:48 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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.2507.23 via Frontend Transport; Fri, 11 Aug 2023 05:47:48 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 37BAllns060381; Fri, 11 Aug 2023 05:47:48 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v9 06/13] media: cadence: csi2rx: Configure DPHY using link freq Date: Fri, 11 Aug 2023 16:17:28 +0530 Message-ID: <20230811-upstream_csi-v9-6-8943f7a68a81@ti.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230811-upstream_csi-v9-0-8943f7a68a81@ti.com> References: <20230811-upstream_csi-v9-0-8943f7a68a81@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1917; i=j-luthra@ti.com; h=from:subject:message-id; bh=MbEUtCGTIMiWhE0Nm9ZqdY4oWREymewboSsVKOIiK2U=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBk1g7+NV9wdQwO2FExNgMMFOvIADTbDas/NQKxh WhwlXC5jteJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZNYO/gAKCRBD3pH5JJpx RSFtD/4gCwHRlIjhB+Ye9qCxgcBUhHbri6BwdH0q6wQ1lUs4J6q2rVn9vFjxyJORswzN5Xsp2qG RTW/z/XEGjMrEXAe3OeHnIVD1FUTKQk9c38envuBFZijX5rCL9zezbOYyB59hTrm8LQhl77jYXm skpr5wvo6tILnxaWVtQ7g5/qe9mlXjoO8Xk3oHwjMvlWcMevQrabj9hddMQ4S5kJtDGf9q/8Fxa wgHVx0FRq4rr6cYmd/xhVdFbacfaKMTN1dbye8n9eUf7uQ2B9yn76qxS4R2R/Ma9P7abtgBrk0D 4l1qcMomS1jbyDrQN7llimpVLO8q35milsCsq6qid2wRf/15WtUonNiJ8jLVrCs4DdpfZgxwmw8 A+yH4kX6440wqHk/yoNC7wWP+p1xkD9sUAMtewKgIKKkIhuFStre6cW0G/OvlyCNQ7KxB8s0rtH fJfWdJIC4JSHZEO3l66Ptf+wH7aotxO8IEcSpQ4sVvr0TlorLeeneO/06wCToYUWHsXlgY7P2c6 zFDHgSs1WIIbXJNypHHCeXxTC2v2ZLLCJ4EKJXNyksqtf9w0HELBoO1nEymsPy09pprrteft3qw Vz0rofmuNE+xK0vLkoAul6KMV2K7js2jZOGUjwd8LoB3Qv4EuaugDU2CJS5eZ3BZiOT+sbQku57 EqX9BWWicpw+b0A== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 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-20230811_034840_612202_39858F25 X-CRM114-Status: GOOD ( 13.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Pratyush Yadav Some platforms like TI's J721E can have the CSI2RX paired with an external DPHY. Use the generic PHY framework to configure the DPHY with the correct link frequency. Signed-off-by: Pratyush Yadav Co-authored-by: Jai Luthra Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Signed-off-by: Jai Luthra --- Changes from v8: - Don't specify stream while calling .get_fmt() drivers/media/platform/cadence/cdns-csi2rx.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 047e74ee2443..933edec89520 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -145,8 +145,32 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx) static int csi2rx_configure_ext_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 = { + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .pad = CSI2RX_PAD_SINK, + }; + const struct csi2rx_fmt *fmt; + s64 link_freq; int ret; + ret = v4l2_subdev_call_state_active(&csi2rx->subdev, pad, get_fmt, + &sd_fmt); + if (ret < 0) + return ret; + + fmt = csi2rx_get_fmt_by_code(sd_fmt.format.code); + + link_freq = v4l2_get_link_freq(csi2rx->source_subdev->ctrl_handler, + fmt->bpp, 2 * csi2rx->num_lanes); + if (link_freq < 0) + return link_freq; + + ret = phy_mipi_dphy_get_default_config_for_hsclk(link_freq, + csi2rx->num_lanes, cfg); + if (ret) + return ret; + ret = phy_power_on(csi2rx->dphy); if (ret) return ret;