From patchwork Mon Jul 31 08:29:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 13334018 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 54F35C001DE for ; Mon, 31 Jul 2023 08:31:02 +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=TEP+RNLs2l7gub4EY5h0wlgcsVhzcjMw/BaA4+6kIlg=; b=36ejatnVP0hWMW gNLejoazaMDBhqGwaGT9f3oVaNaHnAmdx+vndlIOW8GmQQjfZ5hZ8bBSLljU0hHrGnSK0dVkoWBI9 Do/dyWTT929CFj3W5ufHnLZ6PasAMGdFzHlXR0warHrD34Bue0J+Z91ZM5/AetgWqz08obrWheNvH 4uOegx5GkZj2IqePPrVO0atJBEUw0wk1+aKlLFKJOjd8pD9HLTIJUwWG3vfEdegxevLyI6r0qDFn1 1zhewycU8XuoH0pFCiscZ3wJSYd7XqX1o7FN/kbOuXnWCgcD3MthGDSK7XieW1ZxJdzi5a2r3qyVN m/e2/zTN1c++oGLwS36A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQOIN-00EXSx-1H; Mon, 31 Jul 2023 08:30:27 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQOHm-00EX6l-0e for linux-arm-kernel@lists.infradead.org; Mon, 31 Jul 2023 08:29:52 +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 36V8TiJV054937; Mon, 31 Jul 2023 03:29:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1690792184; bh=E9UkcS+2VXbNP1qkq12sT+ScQLrPo9DPV31sM7WES4k=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=B33Hlm9iLPjIJwb3g26K0a9wPzpP/V87bw5IrUWs2ypo7cecEyzvM2vu3Z0R9Oe8P zPPPKOFdka/iXlVaS2t00Kf/3CTGXi6tiQh87P74VmQn3/kGwquyfAVSt3mN7clVNj VpW+W6mhfTUsa4TydOHxCMvLs9RoTIYmhihortyU= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 36V8Timm106712 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 31 Jul 2023 03:29:44 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) 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.2507.23; Mon, 31 Jul 2023 03:29:44 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE101.ent.ti.com (157.170.170.31) 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; Mon, 31 Jul 2023 03:29:44 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 36V8ThOw041923; Mon, 31 Jul 2023 03:29:44 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Laurent Pinchart , Tomi Valkeinen CC: , , , , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , Subject: [PATCH v8 08/16] media: cadence: csi2rx: Configure DPHY using link freq Date: Mon, 31 Jul 2023 13:59:26 +0530 Message-ID: <20230731-upstream_csi-v8-8-fb7d3661c2c9@ti.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731-upstream_csi-v8-0-fb7d3661c2c9@ti.com> References: <20230731-upstream_csi-v8-0-fb7d3661c2c9@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1977; i=j-luthra@ti.com; h=from:subject:message-id; bh=lP78AAgdw8HiC/cJJfwyiOGaiGILwVLLk4FS6A1HMsg=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBkx2xqP3MEVfG3j+vK71esq1Pw3SZABy+HUN0Ny M1nBEB7X0SJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZMdsagAKCRBD3pH5JJpx RQUBD/9TQBQOcP/dYirvERLs4rZYIVZEt8J/BV1Z53D2ldbo3kjsrzqWKuTLkKGtrk7ZW81bOIm F16Jlbf0wBnVeDCRCYos1r5UDFqFCslsouyhFJueNgZY0MC5GAVSojwIjayDu9e4Y+4RySKChTz Krcgcke597uA62cuUwKb3aIYlKs33NwFCO9cxNFbPzL0vZKDNnOAYwwlnIImCJOwLOBNktgI7e3 MWlqRD6m9UQUBhkHxg/ioyQF5QV833WFoH2qbbTkeD7wu2vSP53Tdtbem6V0h4i1kbug64HFXNS zPo6CRI9FcA5PWNf98lGMX1QT3xkov9VqrrO+KDgJcyG8OmM0plKExiqY+zt1wc9TWDe2IYJjvM sxB2f+fpasDnpD3c9yBaNDa6ButwPhGQl+lE5bTg9myo0Am2KhNvbPoKedYrnDDWwF4V9E57LKK 1eE+XurVzM/GDoIh9FVziNUZ74dkWMSuehBrxnlD6MBCvTBAjzGHtN5IAJCTeyX2BQitbmwsCyD +Vhoecf+PU/nltqPHTS8run8jrZvjvRPEn6ceo5DzWosldwucLOvbu7j3j1orPeAj9O5fk7YvyA C58eYBGd3KqMk506ZrMY1h5HUf1jtUsg0iFpYgN2NAGL/raV1ZI6/VrSKv/XsW18P30M4z1yFh3 4MgdIGtqXz6GBUg== 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-20230731_012950_337049_CD8DEC9A X-CRM114-Status: GOOD ( 15.30 ) 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 Signed-off-by: Jai Luthra Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen --- v7->v8 - Drop original patch in-lieu of already merged https://lore.kernel.org/linux-media/20230523085626.3295-5-jack.zhu@starfivetech.com/ - Add a new patch to configure DPHY using link_freq control from the source drivers/media/platform/cadence/cdns-csi2rx.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 4f9654366485..2a80c66fb547 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -149,8 +149,33 @@ 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, + .stream = 0, + }; + 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;