linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Faiz Abbas <faiz_abbas@ti.com>
To: <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<netdev@vger.kernel.org>, <linux-can@vger.kernel.org>
Cc: <wg@grandegger.com>, <mkl@pengutronix.de>, <robh+dt@kernel.org>,
	<mark.rutland@arm.com>, <kishon@ti.com>, <faiz_abbas@ti.com>
Subject: [PATCH 6/6] can: m_can: Add support for transceiver as phy
Date: Sat, 3 Nov 2018 00:56:16 +0530	[thread overview]
Message-ID: <20181102192616.28291-7-faiz_abbas@ti.com> (raw)
In-Reply-To: <20181102192616.28291-1-faiz_abbas@ti.com>

Add support for implementing the transceiver device as a phy. Instead
of a child node, the max_bitrate information is obtained by getting a
phy attribute. Fallback to the legacy API if no phy node is found.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
---
 drivers/net/can/m_can/m_can.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 9b449400376b..ed6d84acea20 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -26,6 +26,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/iopoll.h>
 #include <linux/can/dev.h>
+#include <linux/phy/phy.h>
 #include <linux/pinctrl/consumer.h>
 
 /* napi related */
@@ -1582,6 +1583,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
 	struct device_node *np;
 	u32 mram_config_vals[MRAM_CFG_LEN];
 	u32 tx_fifo_size;
+	struct phy *transceiver;
 
 	np = pdev->dev.of_node;
 
@@ -1671,7 +1673,26 @@ static int m_can_plat_probe(struct platform_device *pdev)
 
 	devm_can_led_init(dev);
 
-	of_can_transceiver(dev);
+	transceiver = devm_phy_optional_get(&pdev->dev, "can_transceiver");
+	if (IS_ERR(transceiver)) {
+		ret = PTR_ERR(transceiver);
+		dev_err(&pdev->dev, "Couldn't get phy. err=%d\n", ret);
+		return ret;
+	}
+
+	if (!transceiver) {
+		dev_warn(&pdev->dev, "No transceiver phy. Falling back to legacy API\n");
+		of_can_transceiver(dev);
+	} else {
+		ret = phy_power_on(transceiver);
+		if (ret) {
+			dev_err(&pdev->dev, "phy_power_on err:%d\n", ret);
+			return ret;
+		}
+		priv->can.bitrate_max = phy_get_max_bitrate(transceiver);
+		if (!priv->can.bitrate_max)
+			dev_warn(&pdev->dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit\n");
+	}
 
 	dev_info(&pdev->dev, "%s device registered (irq=%d, version=%d)\n",
 		 KBUILD_MODNAME, dev->irq, priv->version);
-- 
2.18.0


      parent reply	other threads:[~2018-11-02 19:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-02 19:26 [PATCH 0/6] Add Support for MCAN transceivers in AM65x-evm Faiz Abbas
2018-11-02 19:26 ` [PATCH 1/6] phy: Add max_bitrate attribute & phy_get_max_bitrate() Faiz Abbas
2018-11-03  9:36   ` Marc Kleine-Budde
2018-11-05  6:27     ` Faiz Abbas
2018-11-05  9:37       ` Marc Kleine-Budde
2018-11-05 11:14         ` Faiz Abbas
2018-11-05 11:47           ` Marc Kleine-Budde
2018-11-05 13:22             ` Faiz Abbas
2018-11-02 19:26 ` [PATCH 2/6] dt-bindings: phy: phy-of-simple: Document new binding Faiz Abbas
2018-11-06 20:55   ` Rob Herring
2018-11-02 19:26 ` [PATCH 3/6] phy: phy-of-simple: Add support for simple generic phy driver Faiz Abbas
2018-11-03  5:04   ` kbuild test robot
2018-11-02 19:26 ` [PATCH 4/6] dt-bindings: can: m_can: Document transceiver implementation as a phy Faiz Abbas
2018-11-02 19:26 ` [PATCH 5/6] dt-bindings: can: can-transceiver: Remove legacy binding documentation Faiz Abbas
2018-11-03 20:12   ` Sergei Shtylyov
2018-11-02 19:26 ` Faiz Abbas [this message]

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=20181102192616.28291-7-faiz_abbas@ti.com \
    --to=faiz_abbas@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kishon@ti.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@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).