Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp349777pxb; Wed, 14 Apr 2021 17:29:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTlfLQIpN5Ovh1IeG9N7gegzebyNKT5wU7ShU3701zBjTNmxiaFEXk7SLQGSS9t/HlHEyM X-Received: by 2002:a17:906:7d82:: with SMTP id v2mr703401ejo.524.1618446589432; Wed, 14 Apr 2021 17:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618446589; cv=none; d=google.com; s=arc-20160816; b=WB2krN12Xypc5fQFBxgh1bzGidoQXxokMZn2wpaokUrqRLgKldRMoc92XA1AlFIvnR 2aFZMLbOJSeMsYzNjo4zFkwIMWU5/7DhoqZgl0RFCIeePFkkd6ivOtRhB2onKn0Fp58b htvWBakYpgO/0RGUVrivuoVNRV9L4WVJfAPUiWqzI+DqZpylvmAPB+zNrFYOUUYUudYW H0bXoE1h4wLwKhJH8YboDGtuRH3y6OMMaEG4zJ24NnV7xh2m7AiSvoTeHM1P4GgJFbNj U2L1BfSzHOn1sIs/RzUz2BZUsmMPO2LJ4xiQUMkbmw4qw8qNd13HqtqajyG4bh4HfoA4 3P8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:mime-version:references:in-reply-to :message-id:date:subject:cc:from:dkim-signature; bh=Ka1Qy+cOYe6V8+ih28qlwPxSBVP6axSVpbaQDyyCpW8=; b=ssZViqmm5jU7Klg63lj/B0PIC4IMWoY6Il71oLy82+WV2kT9rXReRCUu6ERxrESr5K AjChyTwBcNkH4HVNnf59695Dh/t+pUEbzUgebYIrFKL1SaWLSYBDBNw2ZY1vWcZwdtlr BiThsAu+G7Ufrkkz8MkNco04HHv48cqd49/TLqAvi7Um1I64hKoxpK1Bfa2tO4baxBwC 2LW/noev5LhaeXDc7Ns4GQU3P3db9hC5QQke6lUDVlt1dKks1IMh13PPI1JdcDp7wcos M6/gR3roH5QtF++n2i+/h8ZLXLein73CYZ43ql4G+HCAn8nUu/C+BSi7vcgFEGLKwI2s 1VSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ti.com header.s=ti-com-17Q1 header.b=Ny+VcP1Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b23si831348ejl.90.2021.04.14.17.29.26; Wed, 14 Apr 2021 17:29:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@ti.com header.s=ti-com-17Q1 header.b=Ny+VcP1Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351783AbhDNOHB (ORCPT + 99 others); Wed, 14 Apr 2021 10:07:01 -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 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= 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 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 Content-Type: text/plain 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 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 #include "m_can.h" @@ -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 = netdev_priv(dev); + int err; netif_stop_queue(dev); @@ -1536,6 +1538,14 @@ static int m_can_close(struct net_device *dev) close_candev(dev); can_led_event(dev, CAN_LED_EVENT_STOP); + if (cdev->transceiver) { + err = phy_power_off(cdev->transceiver); + if (err) { + netdev_err(dev, "error powering off phy, err=%d\n", err); + return err; + } + } + return 0; } @@ -1720,6 +1730,14 @@ static int m_can_open(struct net_device *dev) struct m_can_classdev *cdev = netdev_priv(dev); int err; + if (cdev->transceiver) { + err = phy_power_on(cdev->transceiver); + if (err) { + netdev_err(dev, "error powering on phy, err=%d\n", err); + return err; + } + } + err = 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 /* 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; 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.com/ #include +#include #include "m_can.h" @@ -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 = 0; mcan_class = m_can_class_allocate_dev(&pdev->dev, @@ -101,6 +103,18 @@ static int m_can_plat_probe(struct platform_device *pdev) goto probe_fail; } + transceiver = devm_of_phy_optional_get_by_index(&pdev->dev, pdev->dev.of_node, 0); + if (IS_ERR(transceiver)) { + ret = PTR_ERR(transceiver); + dev_err(&pdev->dev, "error while getting phy, err=%d\n", ret); + return ret; + } + + if (!transceiver) + dev_info(&pdev->dev, "No transceiver phy found\n"); + else + priv->cdev.can.bitrate_max = transceiver->attrs.max_link_rate; + priv->base = addr; priv->mram_base = mram_addr; @@ -108,6 +122,7 @@ static int m_can_plat_probe(struct platform_device *pdev) mcan_class->pm_clock_support = 1; mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk); mcan_class->dev = &pdev->dev; + mcan_class->transceiver = transceiver; mcan_class->ops = &m_can_plat_ops; -- 2.17.1