From nobody Sun May 5 03:21:46 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=1620623445; cv=none; d=zohomail.com; s=zohoarc; b=UD/3sBshubtKlkHN7b+WM2SapuvBYWLPrcXNkEQ7K1ZxMdLaztps94z2RqcJhyMWubaUw1pCSigKK+sj5IirOkL8bPiHdpAax+SymhthHtASqLAgtmYT28K7JWGFXuQLoIyvhF4zd5ALsinMgPJ38/dG7pqg2nDgYS+2b3EHmX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620623445; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=D09BNE/QEQl6N7z7qggHPyShQPUog3qk6d/UXkkKZok=; b=AqWsaKlkKWNYn3b8t1Iip8gZ785ZZP5tLTfUKkWT0nSnq5Bh9mxCVmyB8lgLqrQoo5tCq4X4nULGgBEjZCcjjWoyffvgydfOGc2jY//5GjxkJDt6+TjfjfqcyBI9rVBHNuWLrEgHpIxUsEPBBRVO7XqeZ4x31gNd1F+U5HpDhXU= 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 1620623445738903.0317370417856; Sun, 9 May 2021 22:10:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230138AbhEJFLs (ORCPT ); Mon, 10 May 2021 01:11:48 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:50570 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbhEJFLp (ORCPT ); Mon, 10 May 2021 01:11:45 -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 14A5AXvn073470; Mon, 10 May 2021 00:10:33 -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 14A5AXZM061787 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 May 2021 00:10:33 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) 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; Mon, 10 May 2021 00:10:33 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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 via Frontend Transport; Mon, 10 May 2021 00:10:33 -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 14A5A9nM113970; Mon, 10 May 2021 00:10:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1620623433; bh=D09BNE/QEQl6N7z7qggHPyShQPUog3qk6d/UXkkKZok=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=r2NqDbSlCxTcDUFtpoNDlT2l0nFDX1I0MAud9qZxJM/+auuCXkDdO6XbaY6Ocpgf2 ipDGqk09+x2hgOj+6jXJVcjrG0xIc2e3o0CSf7e6jzoxjLF1FQ+9wsEIEkrw7oyZu6 4tpBGRD6rDXOXmvfTPNpDHcPE1OFLBYaqC4k2pAs= From: Aswath Govindraju CC: , Marc Kleine-Budde , Wolfgang Grandegger , Vignesh Raghavendra , Lokesh Vutla , Aswath Govindraju , Kishon Vijay Abraham I , Vinod Koul , Rob Herring , , , Subject: [PATCH v6 1/3] phy: core: Reword the comment specifying the units of max_link_rate to be Mbps Date: Mon, 10 May 2021 10:40:03 +0530 Message-ID: <20210510051006.11393-2-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210510051006.11393-1-a-govindraju@ti.com> References: <20210510051006.11393-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 Acked-by: Marc Kleine-Budde --- 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 03:21:46 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=1620623455; cv=none; d=zohomail.com; s=zohoarc; b=Zx6drDC5TaB2RPwU0KbjSpjcTwGTMpvDzx8WUr3i+dmXHnoFMgT9BbfbvIh9F+hQ0qONIvgazsSDnRNBYaXKnfTzV6aVKbA28zScPi2eEFBFEPYd8hlNUZDl+VERI6oXFGsmNENz0eOShWRr6AnCrGFBTwElMF5AW5sLA789rBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620623455; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=qAt2F4fkclW+C+54d5EikR+ummqe22jnG+GkI6TfYkY=; b=K3gh9wLAHJUaiLkVp04DYgV0furSOBtO9Wud5XEsAtKc1Ath9/S6AiFFYpWIyUI77TI2ryNrMahJNk4XXolwC4DXEnZRxabzUbqfoKQLkSyRLbw1m+XWsiHOQ74SUegsjRGJsaMNTg5yJS5rqF4tZimQs4+ATJRSPbTwKJi4Ix8= 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 162062345517662.72891364973225; Sun, 9 May 2021 22:10:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230145AbhEJFL5 (ORCPT ); Mon, 10 May 2021 01:11:57 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:37680 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbhEJFL4 (ORCPT ); Mon, 10 May 2021 01:11:56 -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 14A5AjBs081038; Mon, 10 May 2021 00:10:45 -0500 Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 14A5AjUD055407 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 May 2021 00:10:45 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) 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; Mon, 10 May 2021 00:10:45 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE111.ent.ti.com (10.64.6.32) 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; Mon, 10 May 2021 00:10:45 -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 14A5A9nN113970; Mon, 10 May 2021 00:10:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1620623445; bh=qAt2F4fkclW+C+54d5EikR+ummqe22jnG+GkI6TfYkY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=RUI76Q/fO6kc2ASBWDSnQPLrn8NEPEDHP+8tWLLXbK1TMCntK26pCWh9rXj3e6DEX KPUnt0Y+PsaC3/aMn19uG9OEFN3V2Svguexf5Unb5L5HObHecorT3z5G1vW+dj1Y08 //twplzARfyVFAHP3rEvKNtEWf4DYgTSCxFGlL5Q= From: Aswath Govindraju CC: , Marc Kleine-Budde , Wolfgang Grandegger , Vignesh Raghavendra , Lokesh Vutla , Aswath Govindraju , Kishon Vijay Abraham I , Vinod Koul , Rob Herring , , , Subject: [PATCH v6 2/3] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers Date: Mon, 10 May 2021 10:40:04 +0530 Message-ID: <20210510051006.11393-3-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210510051006.11393-1-a-govindraju@ti.com> References: <20210510051006.11393-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 Acked-by: Marc Kleine-Budde --- .../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 601b5ae0368a..492eb53c0db0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4040,6 +4040,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 03:21:46 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=1620623473; cv=none; d=zohomail.com; s=zohoarc; b=D1kzMYTTeNHJZpPbsmrKf+bTnF9OV1Nl+RiXk2o4uROuK6qBskLkkpS6KQyiFcHr90FWAvM0Z4bMkfCtLrQJcS8M2PkBvJ/H3t+Yl8CR/Jlfz85Ig37KaDsBeAd3Co7YEHTPdEyc+hvxLIw4pssQtgrO7o6RRsrjOn41WvNjf3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620623473; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=Uh1qoqnku6rqZX6bcJktkny0EFpSCkE0+xsfey1mpvk=; b=nrkdkzI2dVf1fd3Fq3nBgNokOXujAPEsaPcOGOkvAdQibgCVJnVDSpHV7f2jOt0RQcdm+MiporZwF8Ax/vE+ihUa5rcy++mCV4h7h/Bida3i8/8KXp7r3W2b2uDdJ3rcPC+qkj5y6DpI2EMhj0zD7HpcvLpDJhc0TeTQZsVqwFc= 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 1620623473168407.0097680148035; Sun, 9 May 2021 22:11:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230154AbhEJFMP (ORCPT ); Mon, 10 May 2021 01:12:15 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:50662 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbhEJFMM (ORCPT ); Mon, 10 May 2021 01:12:12 -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 14A5Awlf073683; Mon, 10 May 2021 00:10:58 -0500 Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 14A5AwHT114666 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 May 2021 00:10:58 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) 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; Mon, 10 May 2021 00:10:58 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE111.ent.ti.com (10.64.6.32) 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; Mon, 10 May 2021 00:10:58 -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 14A5A9nO113970; Mon, 10 May 2021 00:10:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1620623458; bh=Uh1qoqnku6rqZX6bcJktkny0EFpSCkE0+xsfey1mpvk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=OHVlZiV1Pp8wCrCViSLYK/tDIENtu9zyKJz9tizB0Eyct/f9IAolSX8k8cf0TfeNo B9aq4G7sE8QDaABAf52DlmobBDfKEbdz/bnwFquajRJsJWvSOHyZtT5v9DPEO8tCwN K4oEUINsRu8D1cVi30wo61Wk/GhDvX4nzT7VWX4Q= From: Aswath Govindraju CC: , Marc Kleine-Budde , Wolfgang Grandegger , Vignesh Raghavendra , Lokesh Vutla , Aswath Govindraju , Kishon Vijay Abraham I , Vinod Koul , Rob Herring , , , Subject: [PATCH v6 3/3] phy: phy-can-transceiver: Add support for generic CAN transceiver driver Date: Mon, 10 May 2021 10:40:05 +0530 Message-ID: <20210510051006.11393-4-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210510051006.11393-1-a-govindraju@ti.com> References: <20210510051006.11393-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 Acked-by: Marc Kleine-Budde --- 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 492eb53c0db0..e7bd53caf5ff 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4042,6 +4042,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..c2cb93b4df71 --- /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 - https://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