devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: mkl@pengutronix.de
Cc: linux-can@vger.kernel.org, qiangqing.zhang@nxp.com,
	robh+dt@kernel.org, devicetree@vger.kernel.org,
	Fabio Estevam <festevam@gmail.com>
Subject: [PATCH 2/2] can: flexcan: allow the control of the STB CAN transceiver pin
Date: Thu,  7 Jan 2021 17:59:15 -0300	[thread overview]
Message-ID: <20210107205915.7602-2-festevam@gmail.com> (raw)
In-Reply-To: <20210107205915.7602-1-festevam@gmail.com>

It is very common to have an STB pin in CAN transceivers, which allows
putting the transceiver in standby or normal operation mode.

Add support for handling the STB pin.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/net/can/flexcan.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 038fe1036df2..094050b4b461 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -17,6 +17,7 @@
 #include <linux/can/rx-offload.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/mfd/syscon.h>
@@ -358,6 +359,8 @@ struct flexcan_priv {
 	struct regulator *reg_xceiver;
 	struct flexcan_stop_mode stm;
 
+	struct gpio_desc *stb;
+
 	/* Read and Write APIs */
 	u32 (*read)(void __iomem *addr);
 	void (*write)(u32 val, void __iomem *addr);
@@ -617,6 +620,8 @@ static void flexcan_clks_disable(const struct flexcan_priv *priv)
 
 static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv)
 {
+	gpiod_set_value_cansleep(priv->stb, 0);
+
 	if (!priv->reg_xceiver)
 		return 0;
 
@@ -625,6 +630,8 @@ static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv)
 
 static inline int flexcan_transceiver_disable(const struct flexcan_priv *priv)
 {
+	gpiod_set_value_cansleep(priv->stb, 1);
+
 	if (!priv->reg_xceiver)
 		return 0;
 
@@ -2044,6 +2051,10 @@ static int flexcan_probe(struct platform_device *pdev)
 		priv->can.bittiming_const = &flexcan_bittiming_const;
 	}
 
+	priv->stb = devm_gpiod_get_optional(&pdev->dev, "stb", GPIOD_OUT_HIGH);
+	if (IS_ERR(priv->stb))
+		return PTR_ERR(priv->stb);
+
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
-- 
2.17.1


  reply	other threads:[~2021-01-07 21:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-07 20:59 [PATCH 1/2] dt-bindings: can: fsl,flexcan.yaml: introduce the stb-gpios property Fabio Estevam
2021-01-07 20:59 ` Fabio Estevam [this message]
2021-01-13  3:23 ` Rob Herring

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=20210107205915.7602-2-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=qiangqing.zhang@nxp.com \
    --cc=robh+dt@kernel.org \
    /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).