Browse Source

can: m_can: Add support for enabling transceiver through the STB line

CAN transceivers on some boards have an STB (standy) line which can be
toggled to enable/disable the transceiver. Add support for enabling the
transceiver using a gpio connected to the STB line.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Faiz Abbas 6 years ago
parent
commit
a6e46181bb
1 changed files with 11 additions and 0 deletions
  1. 11 0
      drivers/net/can/m_can/m_can.c

+ 11 - 0
drivers/net/can/m_can/m_can.c

@@ -15,6 +15,7 @@
 
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
@@ -1580,6 +1581,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
 	struct clk *hclk, *cclk;
 	int irq, ret;
 	struct device_node *np;
+	struct gpio_desc *stb;
 	u32 mram_config_vals[MRAM_CFG_LEN];
 	u32 tx_fifo_size;
 
@@ -1660,6 +1662,15 @@ static int m_can_plat_probe(struct platform_device *pdev)
 	if (ret)
 		goto clk_disable;
 
+	stb = devm_gpiod_get_optional(&pdev->dev, "stb", GPIOD_OUT_HIGH);
+	if (IS_ERR(stb)) {
+		ret = PTR_ERR(stb);
+		if (ret != -EPROBE_DEFER)
+			netdev_err(dev, "gpio request failed, ret %d\n", ret);
+
+		goto clk_disable;
+	}
+
 	ret = register_m_can_dev(dev);
 	if (ret) {
 		dev_err(&pdev->dev, "registering %s failed (err=%d)\n",