diff options
author | Andrew Lunn <andrew@lunn.ch> | 2015-11-19 21:56:23 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-11-23 11:53:10 -0500 |
commit | cc30c16344fc3a25153175c7eb9037b2136cd466 (patch) | |
tree | 47beff192fa89bd934323581f5cc9fed18052a0a /net/dsa | |
parent | 3f8c0f7efb4fcac11f31afa97584d06118c614bb (diff) |
net: dsa: Add support for a switch reset gpio
Some boards have a gpio line tied to the switch reset pin. Allow this
gpio to be retrieved from the device tree, and take the switch out of
reset before performing the probe.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/dsa.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 1eba07feb34a..0b5565f923cc 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/of_mdio.h> | 21 | #include <linux/of_mdio.h> |
22 | #include <linux/of_platform.h> | 22 | #include <linux/of_platform.h> |
23 | #include <linux/of_net.h> | 23 | #include <linux/of_net.h> |
24 | #include <linux/of_gpio.h> | ||
24 | #include <linux/sysfs.h> | 25 | #include <linux/sysfs.h> |
25 | #include <linux/phy_fixed.h> | 26 | #include <linux/phy_fixed.h> |
26 | #include "dsa_priv.h" | 27 | #include "dsa_priv.h" |
@@ -688,6 +689,9 @@ static int dsa_of_probe(struct device *dev) | |||
688 | const char *port_name; | 689 | const char *port_name; |
689 | int chip_index, port_index; | 690 | int chip_index, port_index; |
690 | const unsigned int *sw_addr, *port_reg; | 691 | const unsigned int *sw_addr, *port_reg; |
692 | int gpio; | ||
693 | enum of_gpio_flags of_flags; | ||
694 | unsigned long flags; | ||
691 | u32 eeprom_len; | 695 | u32 eeprom_len; |
692 | int ret; | 696 | int ret; |
693 | 697 | ||
@@ -766,6 +770,19 @@ static int dsa_of_probe(struct device *dev) | |||
766 | put_device(cd->host_dev); | 770 | put_device(cd->host_dev); |
767 | cd->host_dev = &mdio_bus_switch->dev; | 771 | cd->host_dev = &mdio_bus_switch->dev; |
768 | } | 772 | } |
773 | gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, | ||
774 | &of_flags); | ||
775 | if (gpio_is_valid(gpio)) { | ||
776 | flags = (of_flags == OF_GPIO_ACTIVE_LOW ? | ||
777 | GPIOF_ACTIVE_LOW : 0); | ||
778 | ret = devm_gpio_request_one(dev, gpio, flags, | ||
779 | "switch_reset"); | ||
780 | if (ret) | ||
781 | goto out_free_chip; | ||
782 | |||
783 | cd->reset = gpio_to_desc(gpio); | ||
784 | gpiod_direction_output(cd->reset, 0); | ||
785 | } | ||
769 | 786 | ||
770 | for_each_available_child_of_node(child, port) { | 787 | for_each_available_child_of_node(child, port) { |
771 | port_reg = of_get_property(port, "reg", NULL); | 788 | port_reg = of_get_property(port, "reg", NULL); |