summaryrefslogtreecommitdiffstats
path: root/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0108-can-mcp251x-add-reset-gpio-support.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0108-can-mcp251x-add-reset-gpio-support.patch')
-rw-r--r--meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0108-can-mcp251x-add-reset-gpio-support.patch72
1 files changed, 72 insertions, 0 deletions
diff --git a/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0108-can-mcp251x-add-reset-gpio-support.patch b/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0108-can-mcp251x-add-reset-gpio-support.patch
new file mode 100644
index 0000000..646aa0c
--- /dev/null
+++ b/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0108-can-mcp251x-add-reset-gpio-support.patch
@@ -0,0 +1,72 @@
+From b69e3fdc91fbc88cc32eb6794872e1f058681b04 Mon Sep 17 00:00:00 2001
+From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
+Date: Mon, 26 Mar 2018 13:51:49 +0300
+Subject: [PATCH] can: mcp251x: add reset gpio support
+
+Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
+---
+ drivers/net/can/spi/mcp251x.c | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
+index f3f05fe..ac78ce3 100644
+--- a/drivers/net/can/spi/mcp251x.c
++++ b/drivers/net/can/spi/mcp251x.c
+@@ -71,6 +71,7 @@
+ #include <linux/netdevice.h>
+ #include <linux/of.h>
+ #include <linux/of_device.h>
++#include <linux/of_gpio.h>
+ #include <linux/platform_device.h>
+ #include <linux/slab.h>
+ #include <linux/spi/spi.h>
+@@ -270,6 +271,7 @@ struct mcp251x_priv {
+ struct regulator *power;
+ struct regulator *transceiver;
+ struct clk *clk;
++ struct gpio_desc *rst;
+ };
+
+ #define MCP251X_IS(_model) \
+@@ -1031,9 +1033,21 @@ static int mcp251x_can_probe(struct spi_device *spi)
+ struct mcp251x_platform_data *pdata = dev_get_platdata(&spi->dev);
+ struct net_device *net;
+ struct mcp251x_priv *priv;
++ struct gpio_desc *reset_gpio;
+ struct clk *clk;
+ int freq, ret;
+
++ reset_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH);
++ if (IS_ERR(reset_gpio)) {
++ if (PTR_ERR(reset_gpio) == -EPROBE_DEFER)
++ return -EPROBE_DEFER;
++ dev_err(&spi->dev, "cannot get reset-gpios %ld\n",
++ PTR_ERR(reset_gpio));
++ reset_gpio = NULL;
++ } else {
++ gpiod_set_value_cansleep(reset_gpio, 1);
++ }
++
+ clk = devm_clk_get(&spi->dev, NULL);
+ if (IS_ERR(clk)) {
+ if (pdata)
+@@ -1074,6 +1088,7 @@ static int mcp251x_can_probe(struct spi_device *spi)
+ priv->model = spi_get_device_id(spi)->driver_data;
+ priv->net = net;
+ priv->clk = clk;
++ priv->rst = reset_gpio;
+
+ spi_set_drvdata(spi, priv);
+
+@@ -1185,6 +1200,8 @@ static int mcp251x_can_remove(struct spi_device *spi)
+
+ mcp251x_power_enable(priv->power, 0);
+
++ gpiod_set_value_cansleep(priv->rst, 0);
++
+ if (!IS_ERR(priv->clk))
+ clk_disable_unprepare(priv->clk);
+
+--
+1.9.1
+