From nobody Fri May 3 11:36:04 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail(p=quarantine dis=quarantine) header.from=ti.com ARC-Seal: i=1; a=rsa-sha256; t=1618409183; cv=none; d=zohomail.com; s=zohoarc; b=N5AUZ+1rNkVMTWOh5bK/Hj8dkQdctlqtmxXPNOdfjhZz6JyYfTEVwnlga9uEbbcltOkXnZ3I/pZGnDGTL45QtVX/Smxe7dnrJm+uUZliRYqwJkqHy40xGOwou3CLDhbssftz5lnwTt1S3ImiOyQSX/TPXbvsEqDCMcsHrd+CzVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618409183; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=IlU5JTHbgq4me6qjMbuUKqaDA5SuF5DOc/xXRU46LRk=; b=UouUp9AZYV6iZRyLEBfh63cHuPWmT7HE/MtFzaZSc6QSKLF/U98cMgc0cdfupAy7lId2C9+iC62AsxO2Iw8xJHHyghwxs9DpKAhbZCgHX75wrcSdrhVk99yl3a8nQKhg5l3yF7CYtQCrRWdHAn81oymTiwHlH5wf9alcK9Tt0Po= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1618409183742867.9328624851096; Wed, 14 Apr 2021 07:06:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351795AbhDNOGl (ORCPT ); Wed, 14 Apr 2021 10:06:41 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:47940 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348295AbhDNOGS (ORCPT ); Wed, 14 Apr 2021 10:06:18 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5Wgu011837; Wed, 14 Apr 2021 09:05:32 -0500 Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13EE5VZt119446 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Apr 2021 09:05:31 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 14 Apr 2021 09:05:31 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE106.ent.ti.com (10.64.6.27) 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; Wed, 14 Apr 2021 09:05:31 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5Lu9074247; Wed, 14 Apr 2021 09:05:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618409132; bh=IlU5JTHbgq4me6qjMbuUKqaDA5SuF5DOc/xXRU46LRk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=aciUSPPkr5LOFvGp9aEIqjd0H9j5GrYgSaRhrl/7HxHNsJLrTJmuk7dN3f5tZE3P9 5sfk4cppyA/6SMjjCHNNV8C3df1G4pP9FNsI8e4U4ft22pyOm4RHbb05brD3rEfzQF 79CPUwNW08FbPS2xI5Cq6j8tTL0AvtuQ5IHofgck= From: Aswath Govindraju CC: , , , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Jakub Kicinski , Rob Herring , Kishon Vijay Abraham I , Vinod Koul , , , Vignesh Raghavendra , Lokesh Vutla , Grygorii Strashko , Aswath Govindraju Subject: [PATCH v2 1/6] phy: core: Reword the comment specifying the units of max_link_rate to be Mbps Date: Wed, 14 Apr 2021 19:35:16 +0530 Message-ID: <20210414140521.11463-2-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210414140521.11463-1-a-govindraju@ti.com> References: <20210414140521.11463-1-a-govindraju@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In some subsystems (eg. CAN, SPI), the max link rate supported can be less than 1 Mbps and if the unit for max_link_rate is Mbps then it can't be used. Therefore, leave the decision of units to be used, to the producer and consumer. Signed-off-by: Aswath Govindraju --- include/linux/phy/phy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 0ed434d02196..f3286f4cd306 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -125,7 +125,7 @@ struct phy_ops { /** * struct phy_attrs - represents phy attributes * @bus_width: Data path width implemented by PHY - * @max_link_rate: Maximum link rate supported by PHY (in Mbps) + * @max_link_rate: Maximum link rate supported by PHY (units to be decided= by producer and consumer) * @mode: PHY mode */ struct phy_attrs { --=20 2.17.1 From nobody Fri May 3 11:36:04 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail(p=quarantine dis=quarantine) header.from=ti.com ARC-Seal: i=1; a=rsa-sha256; t=1618409180; cv=none; d=zohomail.com; s=zohoarc; b=PBH6HynJ8Mfcte9MQRf0i0m/SfzSDCIN3ZYxLm47oTEo+HFfzh242ANs5z+IdW9Ha3hC6Ith5IBT228Ks1oWvOFbaramh4XhzlkLUTZH2IcCL9rVgDfJuCFz2bfOY04ut8XWlxWpP2DpxHHheJBqqtcbPSe88ZZ1LYMqMI81nlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618409180; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=nOtbADv7gq9oWC93nIeG2KyriW+0wEaqeFfExSfoA3U=; b=AC+1VknXHHCMk0ca2c73xUmtneO935/aj0PGly72WSC+NZ1qHdwcjL7iBHh7/StTueQttUhyD0EDBDOsD5LuDYE27IbSXy8xa1QLH27Ze1Ynp0vllFn3ImL0ANTpnR0zeV/rCM0/0cP+CjXD/v0U4mK4SVdukIZsF3Szm6VB8kw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1618409180417204.75593941018246; Wed, 14 Apr 2021 07:06:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351748AbhDNOGj (ORCPT ); Wed, 14 Apr 2021 10:06:39 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:47944 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347931AbhDNOGS (ORCPT ); Wed, 14 Apr 2021 10:06:18 -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 13EE5bHc011888; Wed, 14 Apr 2021 09:05:37 -0500 Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13EE5a2c041986 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Apr 2021 09:05:36 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) 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; Wed, 14 Apr 2021 09:05:36 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) 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 via Frontend Transport; Wed, 14 Apr 2021 09:05:36 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5LuA074247; Wed, 14 Apr 2021 09:05:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618409137; bh=nOtbADv7gq9oWC93nIeG2KyriW+0wEaqeFfExSfoA3U=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=S2NEY8hPC/8Lpjqh1WebsZZ/UVUExP+RgWh5GBR5CAu2RuX6sJwmQ42ZPrGbuiPRe s1XSm1zbV6uX3PcuYhBXwtugtcEwCtXihY6NexPS01uFR4sbcjtdcO44lb4VFBiAd7 bFCAUKCrMSI/hZqOSHcMXQtN/SVMeRstFXXXtfhQ= From: Aswath Govindraju CC: , , , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Jakub Kicinski , Rob Herring , Kishon Vijay Abraham I , Vinod Koul , , , Vignesh Raghavendra , Lokesh Vutla , Grygorii Strashko , Aswath Govindraju Subject: [PATCH v2 2/6] phy: Add API for devm_of_phy_optional_get_by_index Date: Wed, 14 Apr 2021 19:35:17 +0530 Message-ID: <20210414140521.11463-3-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210414140521.11463-1-a-govindraju@ti.com> References: <20210414140521.11463-1-a-govindraju@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add API for devm_of_phy_optional_get_by_index, to obtain a reference to an optional phy by index. Signed-off-by: Aswath Govindraju --- drivers/phy/phy-core.c | 26 ++++++++++++++++++++++++++ include/linux/phy/phy.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index ccb575b13777..bf06d4e0ede2 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -839,6 +839,32 @@ struct phy *devm_of_phy_get(struct device *dev, struct= device_node *np, } EXPORT_SYMBOL_GPL(devm_of_phy_get); =20 +/** + * devm_of_phy_optional_get_by_index() - lookup and obtain a reference to = an optional phy by index. + * @dev: device that requests this phy + * @np: node containing the phy + * @index: index of the phy + * + * Gets the phy using _of_phy_get(), then gets a refcount to it, + * and associates a device with it using devres. On driver detach, + * release function is invoked on the devres data, then, + * devres data is freed. This differs to devm_of_phy_get_by_index() in + * that if the phy does not exist, it is not considered an error and + * -ENODEV will not be returned. Instead the NULL phy is returned, + * which can be passed to all other phy consumer calls. + */ +struct phy *devm_of_phy_optional_get_by_index(struct device *dev, struct d= evice_node *np, + int index) +{ + struct phy *phy =3D devm_of_phy_get_by_index(dev, np, index); + + if (PTR_ERR(phy) =3D=3D -ENODEV) + phy =3D NULL; + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_optional_get_by_index); + /** * devm_of_phy_get_by_index() - lookup and obtain a reference to a phy by = index. * @dev: device that requests this phy diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index f3286f4cd306..c5f32b4fadd6 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -253,6 +253,8 @@ struct phy *devm_of_phy_get(struct device *dev, struct = device_node *np, const char *con_id); struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_nod= e *np, int index); +struct phy *devm_of_phy_optional_get_by_index(struct device *dev, struct d= evice_node *np, + int index); void of_phy_put(struct phy *phy); void phy_put(struct device *dev, struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); --=20 2.17.1 From nobody Fri May 3 11:36:04 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail(p=quarantine dis=quarantine) header.from=ti.com ARC-Seal: i=1; a=rsa-sha256; t=1618409189; cv=none; d=zohomail.com; s=zohoarc; b=jVqTeJt4HFoP2gPJuUiJOHpP8Ryx75Z4wTiU30u/loDNcNkaU1CW2WHVAqcbu6W0YoLmW1+WsZFlSZTR2sA5jFozDzRQhbPx5sc/suf9kziJamAUUmchDLPNGwfQi/tVA6ZqHPKjUshLuJUjYca9nz7FAWVVjOV8dELibV46Wz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618409189; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=SbyTJ4nrIzPbNTHEIea0gu+NlxpkXKwgFDRim/hhn7g=; b=Ab/N/ms2xV72kyYN89eAM6PmqPFRT3Ds8FBfyL2qY/8P4lCw+QFGon/Hdf8W++6fCVQCEWgGH7uVlQl5zUHhieQb9sXfON2P31bi31S8nmWrMbMqukn0bT3+nu77j3/o1nHaq83OinFY2/FVQ4LT+4YwJDLIuhazT5Jx7kqTzXI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1618409189327291.4358198379126; Wed, 14 Apr 2021 07:06:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351804AbhDNOGo (ORCPT ); Wed, 14 Apr 2021 10:06:44 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:33046 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349092AbhDNOGS (ORCPT ); Wed, 14 Apr 2021 10:06:18 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5f8w049791; Wed, 14 Apr 2021 09:05:41 -0500 Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13EE5fFE057032 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Apr 2021 09:05:41 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) 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; Wed, 14 Apr 2021 09:05:41 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE105.ent.ti.com (10.64.6.26) 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; Wed, 14 Apr 2021 09:05:41 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5LuB074247; Wed, 14 Apr 2021 09:05:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618409141; bh=SbyTJ4nrIzPbNTHEIea0gu+NlxpkXKwgFDRim/hhn7g=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xj6v6yYGGZt1t29Qk0f0qFccFV3/eNAcJejciXGwZ98AcnPtDvjo5DLOROMnfnoux KPe7U/dksJlZCtyCMcEkEf9PVYtQ4YkF3odqIMLPgkfSL9wSFNV0rTxEFqEEPYEHbe NzXbedYSLcus8DlNbWlDlfAsXAAx9w9XSTr9f9sM= From: Aswath Govindraju CC: , , , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Jakub Kicinski , Rob Herring , Kishon Vijay Abraham I , Vinod Koul , , , Vignesh Raghavendra , Lokesh Vutla , Grygorii Strashko , Aswath Govindraju Subject: [PATCH v2 3/6] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers Date: Wed, 14 Apr 2021 19:35:18 +0530 Message-ID: <20210414140521.11463-4-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210414140521.11463-1-a-govindraju@ti.com> References: <20210414140521.11463-1-a-govindraju@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add binding documentation for TI TCAN104x CAN transceivers. Signed-off-by: Aswath Govindraju --- .../bindings/phy/ti,tcan104x-can.yaml | 56 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.y= aml diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml b/D= ocumentation/devicetree/bindings/phy/ti,tcan104x-can.yaml new file mode 100644 index 000000000000..4abfc30a97d0 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/phy/ti,tcan104x-can.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: TCAN104x CAN TRANSCEIVER PHY + +maintainers: + - Aswath Govindraju + +properties: + $nodename: + pattern: "^tcan104x-phy" + + compatible: + enum: + - ti,tcan1042 + - ti,tcan1043 + + '#phy-cells': + const: 0 + + standby-gpios: + description: + gpio node to toggle standby signal on transceiver + maxItems: 1 + + enable-gpios: + description: + gpio node to toggle enable signal on transceiver + maxItems: 1 + + max-bitrate: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + max bit rate supported in bps + minimum: 1 + +required: + - compatible + - '#phy-cells' + +additionalProperties: false + +examples: + - | + #include + + transceiver1: tcan104x-phy { + compatible =3D "ti,tcan1043"; + #phy-cells =3D <0>; + max-bitrate =3D <5000000>; + standby-gpios =3D <&wakeup_gpio1 16 GPIO_ACTIVE_LOW>; + enable-gpios =3D <&main_gpio1 67 GPIO_ACTIVE_LOW>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 84ef96a444c3..e666d33af10d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4046,6 +4046,7 @@ W: https://github.com/linux-can T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git F: Documentation/devicetree/bindings/net/can/ +F: Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml F: drivers/net/can/ F: include/linux/can/bittiming.h F: include/linux/can/dev.h --=20 2.17.1 From nobody Fri May 3 11:36:04 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail(p=quarantine dis=quarantine) header.from=ti.com ARC-Seal: i=1; a=rsa-sha256; t=1618409192; cv=none; d=zohomail.com; s=zohoarc; b=mBuSC14kSeygIfVwTEA2pCJ8bQlGlmOOrafqqKUZCxvNgAivzIFBGyREog+dNL+M4OZ2tYnKtvrMKHd37ou/L68mu1GEWLTrO68ghXqiwIoEWGmZ7MQTg/3UneFCruHtm10Yj/Zx3/2bE+m+0Z8THTFTSZjCsNc6CeMrcqg9w2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618409192; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=MyRY0I0AP/JRXTyKWjX42i1P5KYkv5TknwTcfufbT7U=; b=PT4MUweJdYHvaFiOJfPL2CdEtNV92T7+ZS5XnlTLwXmuF+C4hv13PzR8LJgeCQo9h0MEDy+KT3YrOP1qBkNSKd8omPKM1kdJB1IQc3WMP1A/rEfiyfLJi5alXNwCnF4XKVCbkdZ3hjdo6uD+Dzp66C16cDcWh57GIQXyhF0jhRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 16184091927555.516682946024957; Wed, 14 Apr 2021 07:06:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351816AbhDNOGp (ORCPT ); Wed, 14 Apr 2021 10:06:45 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:33082 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351708AbhDNOGY (ORCPT ); Wed, 14 Apr 2021 10:06:24 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5k0T049811; Wed, 14 Apr 2021 09:05:46 -0500 Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13EE5kNx119677 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Apr 2021 09:05:46 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 14 Apr 2021 09:05:46 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE113.ent.ti.com (10.64.6.34) 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; Wed, 14 Apr 2021 09:05:46 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5LuC074247; Wed, 14 Apr 2021 09:05:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618409146; bh=MyRY0I0AP/JRXTyKWjX42i1P5KYkv5TknwTcfufbT7U=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=j3aADMi1VsVshacoEAhR+YfZ8wS+QSPGAUkickG8cHsDQNawwLzuxM2igvgfqyLrF jrycGeFam4BsCT2sj5o9CMu/scAdg5U0C2aXAEpl0V6se3YfOOeDUuG6A31/vZFm5p tUG45+WXT/g2VACOyE9tO1mQTdOu7U69VizzYM8M= From: Aswath Govindraju CC: , , , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Jakub Kicinski , Rob Herring , Kishon Vijay Abraham I , Vinod Koul , , , Vignesh Raghavendra , Lokesh Vutla , Grygorii Strashko , Aswath Govindraju Subject: [PATCH v2 4/6] phy: phy-can-transceiver: Add support for generic CAN transceiver driver Date: Wed, 14 Apr 2021 19:35:19 +0530 Message-ID: <20210414140521.11463-5-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210414140521.11463-1-a-govindraju@ti.com> References: <20210414140521.11463-1-a-govindraju@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The driver adds support for generic CAN transceivers. Currently the modes supported by this driver are standby and normal modes for TI TCAN1042 and TCAN1043 CAN transceivers. The transceiver is modelled as a phy with pins controlled by gpios, to put the transceiver in various device functional modes. It also gets the phy attribute max_link_rate for the usage of CAN drivers. Signed-off-by: Aswath Govindraju --- MAINTAINERS | 1 + drivers/phy/Kconfig | 9 ++ drivers/phy/Makefile | 1 + drivers/phy/phy-can-transceiver.c | 146 ++++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+) create mode 100644 drivers/phy/phy-can-transceiver.c diff --git a/MAINTAINERS b/MAINTAINERS index e666d33af10d..70e1438c372d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4047,6 +4047,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/= mkl/linux-can.git T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git F: Documentation/devicetree/bindings/net/can/ F: Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml +F: drivers/phy/phy-can-transceiver.c F: drivers/net/can/ F: include/linux/can/bittiming.h F: include/linux/can/dev.h diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 54c1f2f0985f..51902b629fc6 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -61,6 +61,15 @@ config USB_LGM_PHY interface to interact with USB GEN-II and USB 3.x PHY that is part of the Intel network SOC. =20 +config PHY_CAN_TRANSCEIVER + tristate "CAN transceiver PHY" + select GENERIC_PHY + help + This option enables support for CAN transceivers as a PHY. This + driver provides function for putting the transceivers in various + functional modes using gpios and sets the attribute max link + rate, for mcan drivers. + source "drivers/phy/allwinner/Kconfig" source "drivers/phy/amlogic/Kconfig" source "drivers/phy/broadcom/Kconfig" diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index adac1b1a39d1..9c66101c9605 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_PHY_LPC18XX_USB_OTG) +=3D phy-lpc18xx-usb-otg.o obj-$(CONFIG_PHY_XGENE) +=3D phy-xgene.o obj-$(CONFIG_PHY_PISTACHIO_USB) +=3D phy-pistachio-usb.o obj-$(CONFIG_USB_LGM_PHY) +=3D phy-lgm-usb.o +obj-$(CONFIG_PHY_CAN_TRANSCEIVER) +=3D phy-can-transceiver.o obj-y +=3D allwinner/ \ amlogic/ \ broadcom/ \ diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transc= eiver.c new file mode 100644 index 000000000000..f2976c1f4d0f --- /dev/null +++ b/drivers/phy/phy-can-transceiver.c @@ -0,0 +1,146 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * phy-can-transceiver.c - phy driver for CAN transceivers + * + * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com + * + */ +#include +#include +#include +#include +#include + +struct can_transceiver_data { + u32 flags; +#define CAN_TRANSCEIVER_STB_PRESENT BIT(0) +#define CAN_TRANSCEIVER_EN_PRESENT BIT(1) +}; + +struct can_transceiver_phy { + struct phy *generic_phy; + struct gpio_desc *standby_gpio; + struct gpio_desc *enable_gpio; +}; + +/* Power on function */ +static int can_transceiver_phy_power_on(struct phy *phy) +{ + struct can_transceiver_phy *can_transceiver_phy =3D phy_get_drvdata(phy); + + if (can_transceiver_phy->standby_gpio) + gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0); + if (can_transceiver_phy->enable_gpio) + gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1); + + return 0; +} + +/* Power off function */ +static int can_transceiver_phy_power_off(struct phy *phy) +{ + struct can_transceiver_phy *can_transceiver_phy =3D phy_get_drvdata(phy); + + if (can_transceiver_phy->standby_gpio) + gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1); + if (can_transceiver_phy->enable_gpio) + gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0); + + return 0; +} + +static const struct phy_ops can_transceiver_phy_ops =3D { + .power_on =3D can_transceiver_phy_power_on, + .power_off =3D can_transceiver_phy_power_off, + .owner =3D THIS_MODULE, +}; + +static const struct can_transceiver_data tcan1042_drvdata =3D { + .flags =3D CAN_TRANSCEIVER_STB_PRESENT, +}; + +static const struct can_transceiver_data tcan1043_drvdata =3D { + .flags =3D CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_EN_PRESENT, +}; + +static const struct of_device_id can_transceiver_phy_ids[] =3D { + { + .compatible =3D "ti,tcan1042", + .data =3D &tcan1042_drvdata + }, + { + .compatible =3D "ti,tcan1043", + .data =3D &tcan1043_drvdata + }, + { } +}; +MODULE_DEVICE_TABLE(of, can_transceiver_phy_ids); + +int can_transceiver_phy_probe(struct platform_device *pdev) +{ + struct phy_provider *phy_provider; + struct device *dev =3D &pdev->dev; + struct can_transceiver_phy *can_transceiver_phy; + const struct can_transceiver_data *drvdata; + const struct of_device_id *match; + struct phy *phy; + struct gpio_desc *standby_gpio; + struct gpio_desc *enable_gpio; + u32 max_bitrate =3D 0; + + can_transceiver_phy =3D devm_kzalloc(dev, sizeof(struct can_transceiver_p= hy), GFP_KERNEL); + if (!can_transceiver_phy) + return -ENOMEM; + + match =3D of_match_node(can_transceiver_phy_ids, pdev->dev.of_node); + drvdata =3D match->data; + + phy =3D devm_phy_create(dev, dev->of_node, + &can_transceiver_phy_ops); + if (IS_ERR(phy)) { + dev_err(dev, "failed to create can transceiver phy\n"); + return PTR_ERR(phy); + } + + device_property_read_u32(dev, "max-bitrate", &max_bitrate); + if (!max_bitrate) + dev_warn(dev, "Invalid value for transceiver max bitrate. Ignoring bitra= te limit\n"); + phy->attrs.max_link_rate =3D max_bitrate; + + can_transceiver_phy->generic_phy =3D phy; + + if (drvdata->flags & CAN_TRANSCEIVER_STB_PRESENT) { + standby_gpio =3D devm_gpiod_get(dev, "standby", GPIOD_OUT_HIGH); + if (IS_ERR(standby_gpio)) + return PTR_ERR(standby_gpio); + can_transceiver_phy->standby_gpio =3D standby_gpio; + } + + if (drvdata->flags & CAN_TRANSCEIVER_EN_PRESENT) { + enable_gpio =3D devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); + if (IS_ERR(enable_gpio)) + return PTR_ERR(enable_gpio); + can_transceiver_phy->enable_gpio =3D enable_gpio; + } + + phy_set_drvdata(can_transceiver_phy->generic_phy, can_transceiver_phy); + + phy_provider =3D devm_of_phy_provider_register(dev, of_phy_simple_xlate); + + return PTR_ERR_OR_ZERO(phy_provider); +} + +static struct platform_driver can_transceiver_phy_driver =3D { + .probe =3D can_transceiver_phy_probe, + .driver =3D { + .name =3D "can-transceiver-phy", + .of_match_table =3D can_transceiver_phy_ids, + }, +}; + +module_platform_driver(can_transceiver_phy_driver); + +MODULE_AUTHOR("Faiz Abbas "); +MODULE_AUTHOR("Aswath Govindraju "); +MODULE_DESCRIPTION("CAN TRANSCEIVER PHY driver"); +MODULE_LICENSE("GPL v2"); --=20 2.17.1 From nobody Fri May 3 11:36:04 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail(p=quarantine dis=quarantine) header.from=ti.com ARC-Seal: i=1; a=rsa-sha256; t=1618409194; cv=none; d=zohomail.com; s=zohoarc; b=DJbQjF7/xch0JFcU7ISHi+lN1EOmqsahb4NzB3ndg1RWlhD6SyUd7EYpsfXmtpfe4yIPOP0a+SvM52ktBA5NkoMTldC49yAcIde2isNN1KnJWpOgdNBuciwg24nYfE0Pk1lulBF/u19rPmk7Q+A1R0zwuYTR+eWLmoFiMkz2GNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618409194; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=BC7NZaFwou0Qy/69BHgGrbZVOjCGaSW7Bk5Vk/gujgA=; b=KGhSUKuJO5Xq6QWGat1ZzJuA5FdKg320V6W0gpu1Nn+5egV8Gt5zrUHVlnUMdORuj1ST3Tmzfx2NEcarXepWyMJl0qG5HSSQG2j7d1llUgOu4XaKk+LqUKySRCwU+i91wY/wTRiIBkgcjuzaFrD/gQAK5jpn0apImm2dEL9Nrck= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 161840919453339.98203744476655; Wed, 14 Apr 2021 07:06:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351775AbhDNOGu (ORCPT ); Wed, 14 Apr 2021 10:06:50 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:48006 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351731AbhDNOG1 (ORCPT ); Wed, 14 Apr 2021 10:06:27 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5pga012048; Wed, 14 Apr 2021 09:05:51 -0500 Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13EE5paX119767 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Apr 2021 09:05:51 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 14 Apr 2021 09:05:50 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE103.ent.ti.com (157.170.170.33) 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; Wed, 14 Apr 2021 09:05:50 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5LuD074247; Wed, 14 Apr 2021 09:05:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618409151; bh=BC7NZaFwou0Qy/69BHgGrbZVOjCGaSW7Bk5Vk/gujgA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=sYJMLWSuwEH5eByJ3dvCx/iP3gbA5yoqO5P5HllCBwhSOyqtwZMsKUKuORququGT6 4xeTBmWDj+vVBGyCnLFv0dPD2Wl3zzaP8eMsDRrJqAeqD3M9v+MzU1FDKh1sM/Fse0 SALsoR7v68WT6bFaik22LhA/9EqI2NccLmnk/GLU= From: Aswath Govindraju CC: , , , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Jakub Kicinski , Rob Herring , Kishon Vijay Abraham I , Vinod Koul , , , Vignesh Raghavendra , Lokesh Vutla , Grygorii Strashko , Aswath Govindraju Subject: [PATCH v2 5/6] dt-bindings: net: can: Document transceiver implementation as phy Date: Wed, 14 Apr 2021 19:35:20 +0530 Message-ID: <20210414140521.11463-6-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210414140521.11463-1-a-govindraju@ti.com> References: <20210414140521.11463-1-a-govindraju@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Faiz Abbas Some transceivers need a configuration step (for example, pulling the standby or enable lines) for them to start sending messages. The transceiver can be implemented as a phy with the configuration done in the phy driver. The bit rate limitation can the be obtained by the driver using the phy node. Document the above implementation in the bosch mcan bindings Signed-off-by: Faiz Abbas Signed-off-by: Aswath Govindraju --- Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml b/D= ocumentation/devicetree/bindings/net/can/bosch,m_can.yaml index 798fa5fb7bb2..25f74db46bae 100644 --- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml +++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml @@ -109,6 +109,9 @@ properties: can-transceiver: $ref: can-transceiver.yaml# =20 + phys: + maxItems: 1 + required: - compatible - reg --=20 2.17.1 From nobody Fri May 3 11:36:04 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail(p=quarantine dis=quarantine) header.from=ti.com ARC-Seal: i=1; a=rsa-sha256; t=1618409205; cv=none; d=zohomail.com; s=zohoarc; b=DtSEUtKonkr5psOKJw28yKc/c69eUQ/Z8nvmlHxK0U3+blq/RceVYbNADMDsUhVOX2/QrGISghgARFbTjBU6F/JAGULqk/8L7LxF4PsXTjqUuAUeW9/8VqSLG1YR3z/1lHQEK38+0OMRmrG5fmg3ee6KkllvckrCWbFZxU2KDZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618409205; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=Ka1Qy+cOYe6V8+ih28qlwPxSBVP6axSVpbaQDyyCpW8=; b=iCXs18cQ5niZWU979rrXt/HmZp27TpOVSN1md41HkS3wIDWD3LBaEeCadqmqWi0l5KtVsjE7zj53uDzkDruVs9HCuNLZaeZ71PxvRFEz/UYt3fyc2u00IDS/x2+u5HQG5pzEhSQ8cIYDrhxpojNznw+ycyFTGjcmE810oik9LIc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1618409205846868.7417011109394; Wed, 14 Apr 2021 07:06:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351851AbhDNOHC (ORCPT ); Wed, 14 Apr 2021 10:07:02 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:48018 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351736AbhDNOGa (ORCPT ); Wed, 14 Apr 2021 10:06:30 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5uij012092; Wed, 14 Apr 2021 09:05:56 -0500 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 13EE5tUD119839 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Apr 2021 09:05:55 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) 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; Wed, 14 Apr 2021 09:05:55 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE106.ent.ti.com (10.64.6.27) 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; Wed, 14 Apr 2021 09:05:55 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13EE5LuE074247; Wed, 14 Apr 2021 09:05:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618409156; bh=Ka1Qy+cOYe6V8+ih28qlwPxSBVP6axSVpbaQDyyCpW8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Ny+VcP1QGW3QORuRtue5oaUxZ/4P4F3GZIbKhsqzvxLUjBT+YqLAKurqJQrn6eTFT yhELoyDWm3JPhyCkqhBpZpZ5jhuN77TlE2epR2WxFCRSu+ZEFMYTjhThYoreEPAwR2 Ih1YNgvIseLF6nADGAPGjaBc5/jRDGjgLYR33aFM= From: Aswath Govindraju CC: , , , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Jakub Kicinski , Rob Herring , Kishon Vijay Abraham I , Vinod Koul , , , Vignesh Raghavendra , Lokesh Vutla , Grygorii Strashko , Aswath Govindraju Subject: [PATCH v2 6/6] can: m_can: Add support for transceiver as phy Date: Wed, 14 Apr 2021 19:35:21 +0530 Message-ID: <20210414140521.11463-7-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210414140521.11463-1-a-govindraju@ti.com> References: <20210414140521.11463-1-a-govindraju@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Faiz Abbas Add support for implementing transceiver node as phy. The max_bitrate is obtained by getting a phy attribute. Signed-off-by: Faiz Abbas Signed-off-by: Aswath Govindraju --- drivers/net/can/m_can/m_can.c | 18 ++++++++++++++++++ drivers/net/can/m_can/m_can.h | 2 ++ drivers/net/can/m_can/m_can_platform.c | 15 +++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 34073cd077e4..4807a1f69cc7 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -21,6 +21,7 @@ #include #include #include +#include =20 #include "m_can.h" =20 @@ -1514,6 +1515,7 @@ static void m_can_stop(struct net_device *dev) static int m_can_close(struct net_device *dev) { struct m_can_classdev *cdev =3D netdev_priv(dev); + int err; =20 netif_stop_queue(dev); =20 @@ -1536,6 +1538,14 @@ static int m_can_close(struct net_device *dev) close_candev(dev); can_led_event(dev, CAN_LED_EVENT_STOP); =20 + if (cdev->transceiver) { + err =3D phy_power_off(cdev->transceiver); + if (err) { + netdev_err(dev, "error powering off phy, err=3D%d\n", err); + return err; + } + } + return 0; } =20 @@ -1720,6 +1730,14 @@ static int m_can_open(struct net_device *dev) struct m_can_classdev *cdev =3D netdev_priv(dev); int err; =20 + if (cdev->transceiver) { + err =3D phy_power_on(cdev->transceiver); + if (err) { + netdev_err(dev, "error powering on phy, err=3D%d\n", err); + return err; + } + } + err =3D m_can_clk_start(cdev); if (err) return err; diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index ace071c3e58c..38cad068abad 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -28,6 +28,7 @@ #include #include #include +#include =20 /* m_can lec values */ enum m_can_lec_type { @@ -82,6 +83,7 @@ struct m_can_classdev { struct workqueue_struct *tx_wq; struct work_struct tx_work; struct sk_buff *tx_skb; + struct phy *transceiver; =20 struct can_bittiming_const *bit_timing; struct can_bittiming_const *data_timing; diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can= /m_can_platform.c index 599de0e08cd7..566ba25fb186 100644 --- a/drivers/net/can/m_can/m_can_platform.c +++ b/drivers/net/can/m_can/m_can_platform.c @@ -6,6 +6,7 @@ // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.co= m/ =20 #include +#include =20 #include "m_can.h" =20 @@ -67,6 +68,7 @@ static int m_can_plat_probe(struct platform_device *pdev) struct resource *res; void __iomem *addr; void __iomem *mram_addr; + struct phy *transceiver; int irq, ret =3D 0; =20 mcan_class =3D m_can_class_allocate_dev(&pdev->dev, @@ -101,6 +103,18 @@ static int m_can_plat_probe(struct platform_device *pd= ev) goto probe_fail; } =20 + transceiver =3D devm_of_phy_optional_get_by_index(&pdev->dev, pdev->dev.o= f_node, 0); + if (IS_ERR(transceiver)) { + ret =3D PTR_ERR(transceiver); + dev_err(&pdev->dev, "error while getting phy, err=3D%d\n", ret); + return ret; + } + + if (!transceiver) + dev_info(&pdev->dev, "No transceiver phy found\n"); + else + priv->cdev.can.bitrate_max =3D transceiver->attrs.max_link_rate; + priv->base =3D addr; priv->mram_base =3D mram_addr; =20 @@ -108,6 +122,7 @@ static int m_can_plat_probe(struct platform_device *pde= v) mcan_class->pm_clock_support =3D 1; mcan_class->can.clock.freq =3D clk_get_rate(mcan_class->cclk); mcan_class->dev =3D &pdev->dev; + mcan_class->transceiver =3D transceiver; =20 mcan_class->ops =3D &m_can_plat_ops; =20 --=20 2.17.1