Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2295877pxj; Sun, 9 May 2021 22:29:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFCfai4Sy0FyHIQKkB2PeA0sI/aT/vlIIhKki2e4MGlIgpqfT+uVxI8auAtyNif2cmL0iT X-Received: by 2002:a17:906:22c6:: with SMTP id q6mr23820821eja.275.1620624577856; Sun, 09 May 2021 22:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620624577; cv=none; d=google.com; s=arc-20160816; b=ts46WjJSZ2YpxkTCMM9mXCCJ7G0+jSiQeRUlmT5J3gjZlJZ5uSlKsMD3QbLJQnRyyi 9cfcSYYl355MqQbIuB3my82FBdbUJTeb5dHNcWOTvhpeJAI/zl47HzH0m7rB2u2mPZ2z reuQhxfUpCDkgaxXsC4Kxh/vrU6MOliUrSYu8uPU9MC5iads67LNvvPPQH5c8ysLqTCa CsDdLho6xAI1pr1fNw9uhuNa9iQuxjRbqlmkyNpgGRe6tYA6CVLYeHUUdNy8d/HArj6a mqXsUxr8SckTkH/U7I5YXqPTSwFKjyqi5q4ky3xCBycBpqdP/26EVdJV2yAnVVDIZJqx 56pQ== 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=+LgbeEpcGAX1uaIBoLFr6F1+kThw6gjG8L/0QWGfkRY=; b=vKZgdKCXHktDmjjUHQuT9IljOMzcB1lPHEUWTy07aM/v2sW0SnXi7chMpcGYwZr+hG WxkJbsEhCjs1auT7umX5K1QGOUdZSVQkQzZu0/pzPX/nPL1WA4BZUwqaM4VzvpT5iJTS lPsMoxaks/j7vUNXLVgqg933dFqoSy0upR9I4ZHyW1pY/8HIW5jD8fR5cW9zxVZKz1Q0 v5IiVAH6W+h5qatmh1CQUuWdnDK0+RRuk2D2X6amsTkyzV+MKLWV/kVlTyaWruDI7gkO 2Qee+B+hYH/qdv/S/V07m5QLE7ImxhySUUjgXOUlFewsYRRKgyoZUPlAU7eQMzzsE627 tM6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ti.com header.s=ti-com-17Q1 header.b=eSZHJG0w; 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 n26si12932867edr.190.2021.05.09.22.29.12; Sun, 09 May 2021 22:29:37 -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=eSZHJG0w; 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 S230140AbhEJF1c (ORCPT + 99 others); Mon, 10 May 2021 01:27:32 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:53424 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbhEJF1X (ORCPT ); Mon, 10 May 2021 01:27:23 -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 14A5QAEu078564; Mon, 10 May 2021 00:26:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1620624370; bh=+LgbeEpcGAX1uaIBoLFr6F1+kThw6gjG8L/0QWGfkRY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=eSZHJG0wsxYsO7+qEgWymP9/SgPkv3IiMY4IJy3toL3JjIXqUHoKnklzmcCY/q8dF oqwEBX4UoS2yLab//TfZksBdHwqsafaEdLmT6XJ77KQ9RtdcsvBmNTiXkPQznquemV z/zAOlbSvjiFt1lG7NrKDnldv9ZVjuQVGjgWj3rU= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 14A5QAEE084465 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 May 2021 00:26:10 -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; Mon, 10 May 2021 00:26:09 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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; Mon, 10 May 2021 00:26:09 -0500 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 14A5PfCo045426; Mon, 10 May 2021 00:26:01 -0500 From: Aswath Govindraju CC: Chandrasekar Ramakrishnan , Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Jakub Kicinski , Rob Herring , , , , , Vignesh Raghavendra , Lokesh Vutla , Kishon Vijay Abraham I , Aswath Govindraju Subject: [PATCH v4 2/2] can: m_can: Add support for transceiver as phy Date: Mon, 10 May 2021 10:55:41 +0530 Message-ID: <20210510052541.14168-3-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210510052541.14168-1-a-govindraju@ti.com> References: <20210510052541.14168-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 | 11 +++++++++++ drivers/net/can/m_can/m_can.h | 2 ++ drivers/net/can/m_can/m_can_platform.c | 13 +++++++++++++ 3 files changed, 26 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 3cf6de21d19c..afbecc35d3b6 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; } @@ -1721,6 +1727,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; @@ -1781,6 +1791,7 @@ static int m_can_open(struct net_device *dev) close_candev(dev); exit_disable_clks: m_can_clk_stop(cdev); + phy_power_off(cdev->transceiver); 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..f102d532b7f0 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_probe(&pdev->dev, ret, "failed to get phy\n"); + return ret; + } + + if (transceiver) + mcan_class->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