From nobody Sun May 5 23:13:07 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=1618572707; cv=none; d=zohomail.com; s=zohoarc; b=ZVcDAfpqq8WV9XnySYWCRZZGLaiaGzagjsLFMuJMSMylKrOHozhHwbH+Oy6ANqK5q2lUhtMlkW4VbswSixcUxSpUXfbSnQoGLLCWXyy8fXwGVcrwH8tJEA76vVpV88DvE6H0b5TvR91kyrxGH6iVD8vYDoELEcHTUZF2BD2tHwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618572707; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=IlU5JTHbgq4me6qjMbuUKqaDA5SuF5DOc/xXRU46LRk=; b=GcV1jZHwh37qQiIF8bq3TlzOG5BWXGWKMfLTmvNUjxA2kl0jTCnP2bwxw5CqPBNfsa3+VUqILvhWPBhIxrI+JPSogACMcLANJljV0hGsQkWOfb1TJ5UGm/l7e17NFC2irrbXT60FwUovOFGm4BfQkkGxk5ok/iqOLfW6C+/L2+U= 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 1618572707782295.77964266108415; Fri, 16 Apr 2021 04:31:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242098AbhDPLbo (ORCPT ); Fri, 16 Apr 2021 07:31:44 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:46832 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbhDPLbl (ORCPT ); Fri, 16 Apr 2021 07:31:41 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 13GBV7jx106544; Fri, 16 Apr 2021 06:31:07 -0500 Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13GBV7Uv122596 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 16 Apr 2021 06:31:07 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) 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; Fri, 16 Apr 2021 06:31:06 -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; Fri, 16 Apr 2021 06:31:06 -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 13GBUwIv073816; Fri, 16 Apr 2021 06:31:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618572667; bh=IlU5JTHbgq4me6qjMbuUKqaDA5SuF5DOc/xXRU46LRk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HnMQBAeEMo/H52ClX9Jm9ZuhXkLBmMmH2ArgcWYHHEi0hVcxF8dujEpa1pIf+XUNj Dq7URl8wU8NgoOxz+HXWWc1IX+Bv9NZfba9x7e80xdpUQFU67O7h7ucONQaYf6e5CB EUrKq97Lra64A73eUfiqjroYflTgyhCg/n79GhmU= 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 v5 1/3] phy: core: Reword the comment specifying the units of max_link_rate to be Mbps Date: Fri, 16 Apr 2021 17:00:56 +0530 Message-ID: <20210416113058.23815-2-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416113058.23815-1-a-govindraju@ti.com> References: <20210416113058.23815-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 Sun May 5 23:13:07 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=1618572708; cv=none; d=zohomail.com; s=zohoarc; b=Flaapnls5raXdGD53XqrKldWB2G//kpfdte0z4RBJFWtrSiGMB7ahVR9pBIH6jrEHQduKRKNWbcmvjqgLxEwYcIAx3szHPdhYT0nEs810EvKtYTAm2EgBRPAjywH4bH1EjxwFtAFijdXF052XXjKGt3k5FyS3czU7mfGn7Uab0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618572708; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=MelUBgWsylW80+RVjogTPjEFvjvSH2ZwkORUG97pKnw=; b=HLT3uTp4pfc1RcteO8Km/pjoKqN1gLTrC9xoHoG984mvIZY4nE+8b05iYzhAtLT3txbKACYbvXhuz3S4gdYCFyTIWvdlybsCgSnw5MiUqpD2+G7JqAGwgBOcUWHeRgbDC4LZWFWvfS9YRjEZZeL3b5mgoJx9ij5Kewa46OqAKQI= 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 1618572708342153.89415714556117; Fri, 16 Apr 2021 04:31:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242206AbhDPLbr (ORCPT ); Fri, 16 Apr 2021 07:31:47 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:46856 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242094AbhDPLbm (ORCPT ); Fri, 16 Apr 2021 07:31:42 -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 13GBVBTn106567; Fri, 16 Apr 2021 06:31:11 -0500 Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13GBVBUv079822 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 16 Apr 2021 06:31:11 -0500 Received: from DLEE106.ent.ti.com (157.170.170.36) 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.2176.2; Fri, 16 Apr 2021 06:31:10 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) 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; Fri, 16 Apr 2021 06:31:10 -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 13GBUwIw073816; Fri, 16 Apr 2021 06:31:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618572671; bh=MelUBgWsylW80+RVjogTPjEFvjvSH2ZwkORUG97pKnw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=cXlXL83p98zNZgPDUVA5Od5HzvZr7rrVL0UQpvk7Z620uY3SAIl89HzI7h7+0OpxC pL+cc7UjzRUaK7YeVht1nB1s2IX/6GalQf2vh/Z02PCHPHR3+Qau08U2MM2CKFMRTL 7lVVwEo1e1Ie9cI2i0RIjg0jHOYRQ4C5N4pNSlFo= 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 v5 2/3] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers Date: Fri, 16 Apr 2021 17:00:57 +0530 Message-ID: <20210416113058.23815-3-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416113058.23815-1-a-govindraju@ti.com> References: <20210416113058.23815-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 Reviewed-by: Rob Herring --- .../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..6107880e5246 --- /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: "^can-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: can-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 Sun May 5 23:13:07 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=1618572708; cv=none; d=zohomail.com; s=zohoarc; b=kKVfEcIDN9ct8EXZK3kFmNMrlmGi2wPaiFiV0jPZV427ccqLiAJCpsIXxJnsG9LzzrPtSvNmjH35lK8w6OKfSeoV6JW7bywfSYWTqhuPtMdjrHMNirQE0jkFIego5TcivoGXIqSfVEw0kDNJRYtzGK2wh7GUyOSNHQZ4KZXYmyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618572708; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=VmgmtwzZKjz1jQleLdA0AJVV6DB8etT9Tq1Jw2N+Nbw=; b=BFXcyL5/PTyJdtdKGU1ucR18bSBybcVJKrSMKpYewxGPpB6Kj5Rc9vka+ePLqFmbOt4NERzVimW6vVJsaGRsF+S0gQIRKMo2JKuTixD2PcpuQszbLIVll4u2bjCnNSWCyIlwslwfUDqG+ri/2F5W1gFG6ldals82gf4mcq06o+w= 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 1618572708665481.7867459314093; Fri, 16 Apr 2021 04:31:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242227AbhDPLbv (ORCPT ); Fri, 16 Apr 2021 07:31:51 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:46912 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242202AbhDPLbr (ORCPT ); Fri, 16 Apr 2021 07:31:47 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 13GBVFKD106587; Fri, 16 Apr 2021 06:31:15 -0500 Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13GBVFUk122789 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 16 Apr 2021 06:31:15 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 16 Apr 2021 06:31:14 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) 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; Fri, 16 Apr 2021 06:31:14 -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 13GBUwIx073816; Fri, 16 Apr 2021 06:31:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618572675; bh=VmgmtwzZKjz1jQleLdA0AJVV6DB8etT9Tq1Jw2N+Nbw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=YwdWG3HpimQSHVgcf88dxiB+WAz63hL5VbOvjmyhEfU7EUZhblVB6EzlZoX8R03rC Fzh9OOCWZunIx6CpTEXlJVXTh9RiPBrNFRmHtdI88dg0iK9fFmIEmJFhIbnbyPb2o/ R4TFmRTN0vdjp+h92ArhfAHuvIIWLpxGRuDLgHqU= 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 v5 3/3] phy: phy-can-transceiver: Add support for generic CAN transceiver driver Date: Fri, 16 Apr 2021 17:00:58 +0530 Message-ID: <20210416113058.23815-4-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416113058.23815-1-a-govindraju@ti.com> References: <20210416113058.23815-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..7dd35f1b9cc5 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 CAN 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