Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp459143pxv; Thu, 24 Jun 2021 11:42:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHAIysIadloCnst95Ao8bCSYcnuoNZDxwntA7Wp1ZI3NxhCfHi5f781vvm9+vY2DPha9Vb X-Received: by 2002:a02:b786:: with SMTP id f6mr5973481jam.65.1624560163601; Thu, 24 Jun 2021 11:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624560163; cv=none; d=google.com; s=arc-20160816; b=zRJKLoHLc2vSh5iconqXFbcwdhNY3kGds+01pxgnn40HuYoYS5bshFC+cbXRN8HV9K 0KrkW8VywH87t1kCeQpwjrI+DOrRXmafFk2h5QNrBw3uD3EZ+pWfDudU/MDR5FR5Ldh5 wDaczAZNwYf2HX46uz5x3az3pkcSPMZGnN7xuK9ON/mBJA+FaenjguD+ctgr7aJPPY1A PCXDNjtgOMIFflf3YXDKCLYmfsjdVLiuFGeH6DEiTKjBFTk0q9bBbEbkJ8lTDSUhbudu qN5D/4HeURVJeLN7jd8Pj8DCllmwQfSxbDMC9Kcff6d5MzcUDlsoDne2Z+yJ3GjxePWm WyIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pEYv/cVE8dpSFqbeMd7nSL6UuSjcYO8ph/UZQDKS7+g=; b=gwy0O/4+c1CC5Vg2sANCtO0dv1ZObDM9Etb3l5bWfdeKKH8oZT8BtZWR+FZ/+ymZA4 hdScPuegStlqysFtdpLTSeZgFCE2AsmhL3w6wjeRIk9mUBQXz5y40BmReEjYXM5IhyjQ 8HPyKsux7UdmM8LHD3JdSrFLuZUy7QfSRmhQmOpZLmuT6FR98InA7mR1BKo1UMZabZmX 0GSPHGl4TrsPUd7D8usXFaqPTKhYruzIteKugHhyxn5Y6iuQ91hJL2dUfCJbj9ybIbif yrbtY4xf3IIIFsnEdJ6/sZqD1aBnlu9xMS7NEJnUTcFdFJWFCyBripXqn17D+BM+mukp CJfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BVUI5Gfy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si3980143ila.30.2021.06.24.11.42.31; Thu, 24 Jun 2021 11:42:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BVUI5Gfy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232685AbhFXSn7 (ORCPT + 99 others); Thu, 24 Jun 2021 14:43:59 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:41514 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232541AbhFXSny (ORCPT ); Thu, 24 Jun 2021 14:43:54 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 15OIfOTw028676; Thu, 24 Jun 2021 13:41:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1624560084; bh=pEYv/cVE8dpSFqbeMd7nSL6UuSjcYO8ph/UZQDKS7+g=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BVUI5Gfyfsf0T/wpgVpifLysKV5HCcdTvI9Hn6+ldp57PnSawo0/UdvkFArQA/dNM RCqgpFBxwgAmreBc28a+Yb9ExdDNADqdHfz/dA6Rq7OmsmR+Txk8kZvxVuoiGpEDJH DzK1Z0+qsmrA5hBlAIeIGdvN2imX3xDqeXUmbJSc= 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 15OIfOAd034296 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 24 Jun 2021 13:41:24 -0500 Received: from DLEE106.ent.ti.com (157.170.170.36) 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; Thu, 24 Jun 2021 13:41:24 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE106.ent.ti.com (157.170.170.36) 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; Thu, 24 Jun 2021 13:41:23 -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 15OIf9I0041395; Thu, 24 Jun 2021 13:41:21 -0500 From: Pratyush Yadav To: Vinod Koul CC: Nikhil Devshatwar , Tomi Valkeinen , Laurent Pinchart , Paul Kocialkowski , Vignesh Raghavendra , Pratyush Yadav , Chunfeng Yun , Kishon Vijay Abraham I , Peter Chen , , Subject: [PATCH v3 3/7] phy: cdns-dphy: Allow setting mode Date: Fri, 25 Jun 2021 00:11:04 +0530 Message-ID: <20210624184108.21312-4-p.yadav@ti.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210624184108.21312-1-p.yadav@ti.com> References: <20210624184108.21312-1-p.yadav@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- (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