Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp887956pxb; Thu, 15 Apr 2021 08:49:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmPLJo1T6YN+2J/sHXOoJyo0ZP0uiAxU65toctFseZxFSNaSAxbeVRm9yXC7NGvoJDl4w8 X-Received: by 2002:a05:6402:c:: with SMTP id d12mr4962164edu.100.1618501754155; Thu, 15 Apr 2021 08:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618501754; cv=none; d=google.com; s=arc-20160816; b=bdKrFRnFS2vRSwYUfBF5pmwpXQPiGAwOZ3SKJXrivQY1F4ii1o9M1zn3Okxan9gvcy mKY/wRr4NqFuU/P2yGQgKK51OCsYKiSDQdvWv0l9n7IySgeMZgP8xWij84XCw41PDaSe +hcKE9OWQrrxpplOVTTR6V77HW5HAJEN2GvNxnfX85LX4QQnFtS9maVn4LMWdXTe5eYh 1KT7j4Vxkqyf6Y5SdSYt+w6qxM2y+ftjBUj0k4wSIoN+/dq3r0GVGHO5TmBYiqB6qfkQ azbgSAUYRrI6sXi+U/UzeNHXy3An3T+FRGyRLqJWnjmZ253iTXfxVb/OvlxvzU3tXCc9 pe2w== 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=CdZ9oshP2falxuzkJO0kpQCliVu8gBkJaVPUci3GgOs=; b=FVoxL4hHcXbM6QR1fk1ADYdBdPfGmQeB5qhLHbu0O3/nCiiy72DUFjTvoF39Y1LFuT BF7PE42E3sPjj3LXlqXE/7rd86ObE/bJPm85WxIXsGp2iLfK3ibZM3yU8aYMnOmPAEHg d0ySf5aQfgxeCmRNQfUX6DBZyPwV8Q4CaNYWrV+CPfs/9iNoW63PdULkYxZf1pjg5pl5 o3IDNwA5iSP733MDgE8MAKP+PRJjbQ8iVqjo6XMrR29sUWJh6DahDU0hUiNgF1R4qZqA TWDmxF4Yc3526wDmhGR6EGJz8weJb1eM170IyKU9KUqNxqkommV7PfWs3iAjFEnXFdwq IVkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ti.com header.s=ti-com-17Q1 header.b=SWgzlWD2; 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 e12si2736461edz.568.2021.04.15.08.48.34; Thu, 15 Apr 2021 08:49:14 -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=SWgzlWD2; 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 S233926AbhDOPrZ (ORCPT + 99 others); Thu, 15 Apr 2021 11:47:25 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:34770 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233906AbhDOPrW (ORCPT ); Thu, 15 Apr 2021 11:47:22 -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 13FFko9t028162; Thu, 15 Apr 2021 10:46:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618501610; bh=CdZ9oshP2falxuzkJO0kpQCliVu8gBkJaVPUci3GgOs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SWgzlWD2ve+yUAROdQ/+cZuQg3lUx91opEf8DGoH9P5OBPaxHFhbEMahoC9PCJ3/C L/vLTyzuA4s+u4AzPVo2ettvxodbqW0xJNSkIV+4PSRGtjYxvrs5A3a8PeXOEIc6qD TPqEg+O/2y+7jjTcvXaRVCL68jx/9m9T/eqJLwzg= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13FFko10077354 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 15 Apr 2021 10:46:50 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) 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 10:46:49 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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 via Frontend Transport; Thu, 15 Apr 2021 10:46:49 -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 13FFkZhB028376; Thu, 15 Apr 2021 10:46:45 -0500 From: Aswath Govindraju CC: , , , , Marc Kleine-Budde , Wolfgang Grandegger , Rob Herring , "David S . Miller" , Jakub Kicinski , Chandrasekar Ramakrishnan , Kishon Vijay Abraham I , Lokesh Vutla , Vignesh Raghavendra , Grygorii Strashko , Faiz Abbas , Aswath Govindraju Subject: [PATCH v2 2/2] can: m_can: Add support for transceiver as phy Date: Thu, 15 Apr 2021 21:16:35 +0530 Message-ID: <20210415154635.30094-3-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210415154635.30094-1-a-govindraju@ti.com> References: <20210415154635.30094-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 | 10 ++++++++++ drivers/net/can/m_can/m_can.h | 2 ++ drivers/net/can/m_can/m_can_platform.c | 13 +++++++++++++ 3 files changed, 25 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 34073cd077e4..7d31250446c2 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,10 @@ static int m_can_close(struct net_device *dev) close_candev(dev); can_led_event(dev, CAN_LED_EVENT_STOP); + err = phy_power_off(cdev->transceiver); + if (err) + return err; + return 0; } @@ -1720,6 +1726,10 @@ static int m_can_open(struct net_device *dev) struct m_can_classdev *cdev = netdev_priv(dev); int err; + err = phy_power_on(cdev->transceiver); + if (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..82d4f1a15dd7 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,16 @@ static int m_can_plat_probe(struct platform_device *pdev) goto probe_fail; } + transceiver = devm_phy_optional_get(&pdev->dev, NULL); + if (IS_ERR(transceiver)) { + ret = PTR_ERR(transceiver); + dev_err(&pdev->dev, "error while getting phy, err=%d\n", ret); + return ret; + } + + if (transceiver) + priv->cdev.can.bitrate_max = transceiver->attrs.max_link_rate; + priv->base = addr; priv->mram_base = mram_addr; @@ -108,6 +120,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