From nobody Mon May 6 12:49:11 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=1618498252; cv=none; d=zohomail.com; s=zohoarc; b=Zz88ENzIo2X+f2wau0xzLrxVV7yhJjDx2JW3KWkmqxlU0JQUrXx/0uYrWuCbkg3a6UuBoifOYsoqjRhldpsXpQ/xca4dP0DnuzgEzCb+SqLAb+LKTx77WXK7heOcTfzYLuDCJEtE6pGPlctqtg+yvzL1LBnOx7UrEmgy8DHqohI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618498252; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=IlU5JTHbgq4me6qjMbuUKqaDA5SuF5DOc/xXRU46LRk=; b=NIuLAkb51Pi7RFRtWn+hOKFVJvwBjRh1LRaglKjbCfasNMUYL+NJapYBjLRbgepPHl+6CMaKL620DuxtndJ12BK+dXvOG6hI5/HWchHM6oZgXn5c75WwZeYIK0Cww7BdXrDEGxNS/UiIFYhMAqxDqNH7EZcUf8PVHd5xprvCNYw= 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 1618498252283644.9403565368394; Thu, 15 Apr 2021 07:50:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234083AbhDOOvN (ORCPT ); Thu, 15 Apr 2021 10:51:13 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:46768 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233914AbhDOOu0 (ORCPT ); Thu, 15 Apr 2021 10:50:26 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 13FEnuTC001463; Thu, 15 Apr 2021 09:49:56 -0500 Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13FEntSQ102440 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 15 Apr 2021 09:49:56 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) 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; Thu, 15 Apr 2021 09:49:55 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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 via Frontend Transport; Thu, 15 Apr 2021 09:49:55 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13FEnlS6037772; Thu, 15 Apr 2021 09:49:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618498196; bh=IlU5JTHbgq4me6qjMbuUKqaDA5SuF5DOc/xXRU46LRk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=oQmt65QIIDqGmL3NKotdl7nPTuNh1sUIvajkHQooadd88LQGirIXn3kfGQSiYy4Cb Z+A6IjVjPiOhff7O9gX36bh9ACwMwbVB4N5I81z0YAtcgYxjJp4E5FmJfhFqLwRT5W Tikl2mR4GQ1q+9fh+VDZm1oyas3XpNNPKZclptYg= From: Aswath Govindraju CC: , , , , Kishon Vijay Abraham I , Vinod Koul , Rob Herring , Marc Kleine-Budde , Wolfgang Grandegger , Lokesh Vutla , Vignesh Raghavendra , Grygorii Strashko , Aswath Govindraju Subject: [PATCH v3 1/4] phy: core: Reword the comment specifying the units of max_link_rate to be Mbps Date: Thu, 15 Apr 2021 20:19:44 +0530 Message-ID: <20210415144947.4725-2-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210415144947.4725-1-a-govindraju@ti.com> References: <20210415144947.4725-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 Mon May 6 12:49:11 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=1618498271; cv=none; d=zohomail.com; s=zohoarc; b=aV51YVpYR1j3ZSuPfytAXdLQKD/v90R4xq7I3dzZfoBDO/hpJ8wtSOoj+pL2IWAEC42WdbI1nnHNu0mCFoUIve5W2gPGrYqEIIqmrIxO8LHYcDjWhXQhuQODi8oLfy7ObtOsGm4ItbdLPqU5pWeFYbcNkhl5AypkFp+JgATOHmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618498271; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=nOtbADv7gq9oWC93nIeG2KyriW+0wEaqeFfExSfoA3U=; b=gprqlFz/M2uxBiU2ppzrI7EMBji2dCbJx/I7u+yGISjMhZtrGXQQD9BqSdBunZ5FNCj2hTdSXIlSSc1iOyDjjNV/QF5bm3ieIZqA3u8mBkFTUIdV05vhJjlDX1Lvt0SHITEeqIPTT+sjrvxPsfLsCGB43MdsRX0414TDeI2uBS8= 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 1618498271240892.0699519727057; Thu, 15 Apr 2021 07:51:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233998AbhDOOvb (ORCPT ); Thu, 15 Apr 2021 10:51:31 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:46794 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233926AbhDOOu3 (ORCPT ); Thu, 15 Apr 2021 10:50:29 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 13FEnxpV001478; Thu, 15 Apr 2021 09:49:59 -0500 Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13FEnxtq117710 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 15 Apr 2021 09:49:59 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) 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; Thu, 15 Apr 2021 09:49:59 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE112.ent.ti.com (157.170.170.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; Thu, 15 Apr 2021 09:49:59 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13FEnlS7037772; Thu, 15 Apr 2021 09:49:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618498199; bh=nOtbADv7gq9oWC93nIeG2KyriW+0wEaqeFfExSfoA3U=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=leM+XDQgTsgfCQnRn+Rz9/bYVvqi1V4Pj6yX9eFZSDsQGqz9e4dHPSV+nOQbvOG1g WtVzEAYHIvYJ8UUnmwu8btoncZwyM1MT1yY+WRf9aT06jAwU+P+THsu2Va3GK15QQW zHwYL7HpgQxuxXLOxyrWxEJVkGSsz1dcIhsSyEsk= From: Aswath Govindraju CC: , , , , Kishon Vijay Abraham I , Vinod Koul , Rob Herring , Marc Kleine-Budde , Wolfgang Grandegger , Lokesh Vutla , Vignesh Raghavendra , Grygorii Strashko , Aswath Govindraju Subject: [PATCH v3 2/4] phy: Add API for devm_of_phy_optional_get_by_index Date: Thu, 15 Apr 2021 20:19:45 +0530 Message-ID: <20210415144947.4725-3-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210415144947.4725-1-a-govindraju@ti.com> References: <20210415144947.4725-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 Mon May 6 12:49:11 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=1618498284; cv=none; d=zohomail.com; s=zohoarc; b=hV4UMFefi572iQtrNIXeGRaM2OKqXnFYfdl+/dqdsIlTex2QxDf4qz1+T/zjCE76fOCI6SbR1UCHsqzCYhgWHuHMfTtZcJLBo629SQKDsoLCCrqB6VVme/P3jDtLZ9METVkrJHYPM37EMJqqnLhi4zNASXAh0a1fd9y8Wxq1M+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618498284; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=M1iILu9afWboSM4bZWZ0KITVW/vDNjGiQWDGlJeMvug=; b=mdwes9qiyR/RR9HVuQ0wbmZwtsVbSUWEGHy0qKoK3IOe4Oy445l5YD0WMD0ETsXBJ65gcnOfFQv4coR93DKE5wYcSUfz7mWjoQ0NGS8+UvfKQfvuGRa8DZFGMt5PLtlT332hgRkr35QrVM77UNtml94NnnDCXZKNv0YVR1Ci0i4= 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 1618498284072211.00486236581685; Thu, 15 Apr 2021 07:51:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233751AbhDOOvp (ORCPT ); Thu, 15 Apr 2021 10:51:45 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:34740 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233953AbhDOOuh (ORCPT ); Thu, 15 Apr 2021 10:50:37 -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 13FEo4lD096970; Thu, 15 Apr 2021 09:50:04 -0500 Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13FEo4XA085889 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 15 Apr 2021 09:50:04 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) 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; Thu, 15 Apr 2021 09:50:03 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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 via Frontend Transport; Thu, 15 Apr 2021 09:50:03 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13FEnlS8037772; Thu, 15 Apr 2021 09:50:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618498204; bh=M1iILu9afWboSM4bZWZ0KITVW/vDNjGiQWDGlJeMvug=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=PVofGHJkEoypW03RwfmwSNJ0DO1LqtB188qv4OIFiXkK63cBhK39I+s0KbC7jYRpN XldR2GUPrH3AmaDVQj4wY5hCj56U6RTjh2sLlpNLXG9SI4JKfKe8IOqVMG2MHgxR4e eZnkM6LoKK42AAtEC3nGrxPHansyBR/0HJkqeuzo= From: Aswath Govindraju CC: , , , , Kishon Vijay Abraham I , Vinod Koul , Rob Herring , Marc Kleine-Budde , Wolfgang Grandegger , Lokesh Vutla , Vignesh Raghavendra , Grygorii Strashko , Aswath Govindraju Subject: [PATCH v3 3/4] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers Date: Thu, 15 Apr 2021 20:19:46 +0530 Message-ID: <20210415144947.4725-4-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210415144947.4725-1-a-govindraju@ti.com> References: <20210415144947.4725-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..4643b979930a --- /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_HIGH>; + }; 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 Mon May 6 12:49:11 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=1618498289; cv=none; d=zohomail.com; s=zohoarc; b=DGAUDcrEw8hdUafEKk91Rr5klkKmWDaTh9r6PFsQtnYAf7Z0Q6zRzXet3KJIlL5n6aWS56Rg4LGzCAvxARWiMDG27Mb7q2i7xxk7ZdWCHN/BR1mXNT9sYlVgU3EJZ8VBgZA25E6UoUSXEJ/zUuG/rw0joDRYyxV1E0W4W9eGc+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618498289; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=lwxVMlwuqdF0QN7LNGKmmThT0L4EvWg4hfu0HYGlBX0=; b=bCthcc5KnSijBkIhHmkHfwOXw5+3JV/ZSkfOvdNg/Eqi7WnpRkHZk05GeJ1DwDUP7PZ/Cl+CFRYhuhPOM1JowK/CFNFMIfn5NXuG4FxU3tZ5qN+wxAQdSDeSHt9F1IVvSBXwzfXOfGbTOeyAn/hAxwu4IqKF9r7X0xN4piZMi0c= 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 1618498289894307.1058261448071; Thu, 15 Apr 2021 07:51:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234155AbhDOOvu (ORCPT ); Thu, 15 Apr 2021 10:51:50 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:34758 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233610AbhDOOuj (ORCPT ); Thu, 15 Apr 2021 10:50:39 -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 13FEo8oD097004; Thu, 15 Apr 2021 09:50:08 -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 13FEo8kx103175 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 15 Apr 2021 09:50:08 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) 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; Thu, 15 Apr 2021 09:50:07 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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 via Frontend Transport; Thu, 15 Apr 2021 09:50:07 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13FEnlS9037772; Thu, 15 Apr 2021 09:50:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618498208; bh=lwxVMlwuqdF0QN7LNGKmmThT0L4EvWg4hfu0HYGlBX0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=yVBw0QndLY3kK7d0UVAHoHN4vHzJQgpnOu6uZbH87SOyOFAEL54rE5UVootK1Ob9U Bz52pNsqX67BOsU62sYIDJFvpL+bBhjQ7tF0vWY0pFOkwrMrdb5ykapouI16e7H8U2 rO9631C88NY2soUkVFa/8urxTxNZlY2a+Gm7MXDc= From: Aswath Govindraju CC: , , , , Kishon Vijay Abraham I , Vinod Koul , Rob Herring , Marc Kleine-Budde , Wolfgang Grandegger , Lokesh Vutla , Vignesh Raghavendra , Grygorii Strashko , Aswath Govindraju Subject: [PATCH v3 4/4] phy: phy-can-transceiver: Add support for generic CAN transceiver driver Date: Thu, 15 Apr 2021 20:19:47 +0530 Message-ID: <20210415144947.4725-5-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210415144947.4725-1-a-govindraju@ti.com> References: <20210415144947.4725-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..4e868f2a97c7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4048,6 +4048,7 @@ 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: drivers/phy/phy-can-transceiver.c F: include/linux/can/bittiming.h F: include/linux/can/dev.h F: include/linux/can/led.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..01e9efffc726 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -5,6 +5,7 @@ =20 obj-$(CONFIG_GENERIC_PHY) +=3D phy-core.o obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY) +=3D phy-core-mipi-dphy.o +obj-$(CONFIG_PHY_CAN_TRANSCEIVER) +=3D phy-can-transceiver.o 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 diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transc= eiver.c new file mode 100644 index 000000000000..c24aa2eab9e4 --- /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); + +static 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