devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aswath Govindraju <a-govindraju@ti.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Lokesh Vutla <lokeshvutla@ti.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	Aswath Govindraju <a-govindraju@ti.com>,
	Faiz Abbas <faiz_abbas@ti.com>,
	Chandrasekar Ramakrishnan <rcsekar@samsung.com>,
	Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Rob Herring <robh+dt@kernel.org>, Vinod Koul <vkoul@kernel.org>,
	Sriram Dash <sriram.dash@samsung.com>,
	<linux-can@vger.kernel.org>, <netdev@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-phy@lists.infradead.org>
Subject: [PATCH 4/4] can: m_can_platform: Add support for transceiver as phy
Date: Fri, 9 Apr 2021 19:10:54 +0530	[thread overview]
Message-ID: <20210409134056.18740-5-a-govindraju@ti.com> (raw)
In-Reply-To: <20210409134056.18740-1-a-govindraju@ti.com>

From: Faiz Abbas <faiz_abbas@ti.com>

Add support for implementing transceiver node as phy. The max_bitrate is
obtained by getting a phy attribute.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
---
 drivers/net/can/m_can/m_can_platform.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index 599de0e08cd7..4a762b5a21d8 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 <linux/platform_device.h>
+#include <linux/phy/phy.h>
 
 #include "m_can.h"
 
@@ -67,7 +68,9 @@ 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;
+	u32 bitrate_max;
 
 	mcan_class = m_can_class_allocate_dev(&pdev->dev,
 					      sizeof(struct m_can_plat_priv));
@@ -101,6 +104,28 @@ static int m_can_plat_probe(struct platform_device *pdev)
 		goto probe_fail;
 	}
 
+	transceiver = devm_phy_optional_get(&pdev->dev, "can_transceiver");
+	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_warn(&pdev->dev, "No transceiver phy found\n");
+	} else {
+		ret = phy_power_on(transceiver);
+		if (ret) {
+			dev_err(&pdev->dev, "error powering on phy, err=%d\n", ret);
+			return ret;
+		}
+		/* converting from Mbps to bps */
+		bitrate_max = (transceiver->attrs.max_link_rate) * 1000000;
+		if (!bitrate_max)
+			dev_warn(&pdev->dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit\n");
+		priv->cdev.can.bitrate_max = bitrate_max;
+	}
+
 	priv->base = addr;
 	priv->mram_base = mram_addr;
 
-- 
2.17.1


  parent reply	other threads:[~2021-04-09 13:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09 13:40 [PATCH 0/4] CAN TRANSCEIVER: Add support for CAN transceivers Aswath Govindraju
2021-04-09 13:40 ` [PATCH 1/4] dt-bindings: phy: Add binding for TI TCAN104x " Aswath Govindraju
2021-04-12 10:19   ` Marc Kleine-Budde
2021-04-12 17:49     ` Rob Herring
2021-04-13  7:41       ` Marc Kleine-Budde
2021-04-13 13:15         ` Rob Herring
2021-04-14 12:53           ` Aswath Govindraju
2021-04-09 13:40 ` [PATCH 2/4] phy: phy-can-transceiver: Add support for generic CAN transceiver driver Aswath Govindraju
2021-04-12 10:18   ` Marc Kleine-Budde
2021-04-14  6:24     ` Aswath Govindraju
2021-04-14  6:57       ` Marc Kleine-Budde
2021-04-09 13:40 ` [PATCH 3/4] dt-bindings: net: can: Document transceiver implementation as phy Aswath Govindraju
2021-04-12 17:51   ` Rob Herring
2021-04-14  6:49     ` Aswath Govindraju
2021-04-14 13:24       ` Rob Herring
2021-04-09 13:40 ` Aswath Govindraju [this message]
2021-04-12 10:22   ` [PATCH 4/4] can: m_can_platform: Add support for transceiver " Marc Kleine-Budde
2021-04-14  6:59 ` [PATCH 0/4] CAN TRANSCEIVER: Add support for CAN transceivers Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210409134056.18740-5-a-govindraju@ti.com \
    --to=a-govindraju@ti.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=faiz_abbas@ti.com \
    --cc=grygorii.strashko@ti.com \
    --cc=kishon@ti.com \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=lokeshvutla@ti.com \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=rcsekar@samsung.com \
    --cc=robh+dt@kernel.org \
    --cc=sriram.dash@samsung.com \
    --cc=vigneshr@ti.com \
    --cc=vkoul@kernel.org \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).