Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: qca8k: introduce reset via gpio feature

The QCA8337(N) has a RESETn signal on Pin B42 that
triggers a chip reset if the line is pulled low.
The datasheet says that: "The active low duration
must be greater than 10 ms".

This can hopefully fix some of the issues related
to pin strapping in OpenWrt for the EA8500 which
suffers from detection issues after a SoC reset.

Please note that the qca8k_probe() function does
currently require to read the chip's revision
register for identification purposes.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Christian Lamparter and committed by
David S. Miller
a653f2f5 e7dd8a89

+17
+15
drivers/net/dsa/qca8k.c
··· 14 14 #include <linux/of_platform.h> 15 15 #include <linux/if_bridge.h> 16 16 #include <linux/mdio.h> 17 + #include <linux/gpio.h> 17 18 #include <linux/etherdevice.h> 18 19 19 20 #include "qca8k.h" ··· 1046 1045 1047 1046 priv->bus = mdiodev->bus; 1048 1047 priv->dev = &mdiodev->dev; 1048 + 1049 + priv->reset_gpio = devm_gpiod_get_optional(priv->dev, "reset", 1050 + GPIOD_ASIS); 1051 + if (IS_ERR(priv->reset_gpio)) 1052 + return PTR_ERR(priv->reset_gpio); 1053 + 1054 + if (priv->reset_gpio) { 1055 + gpiod_set_value_cansleep(priv->reset_gpio, 1); 1056 + /* The active low duration must be greater than 10 ms 1057 + * and checkpatch.pl wants 20 ms. 1058 + */ 1059 + msleep(20); 1060 + gpiod_set_value_cansleep(priv->reset_gpio, 0); 1061 + } 1049 1062 1050 1063 /* read the switches ID register */ 1051 1064 id = qca8k_read(priv, QCA8K_REG_MASK_CTRL);
+2
drivers/net/dsa/qca8k.h
··· 10 10 11 11 #include <linux/delay.h> 12 12 #include <linux/regmap.h> 13 + #include <linux/gpio.h> 13 14 14 15 #define QCA8K_NUM_PORTS 7 15 16 ··· 175 174 struct mutex reg_mutex; 176 175 struct device *dev; 177 176 struct dsa_switch_ops ops; 177 + struct gpio_desc *reset_gpio; 178 178 }; 179 179 180 180 struct qca8k_mib_desc {