Commit 52638f71 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

dsa: Move gpio reset into switch driver

Resetting the switch is something the driver does, not the framework.
So move the parsing of this property into the driver.

There are no in kernel users of this property, so moving it does not
break anything. There is however a board which will make use of this
property making its way into the kernel.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 14c7b3c3
...@@ -31,8 +31,6 @@ A switch child node has the following optional property: ...@@ -31,8 +31,6 @@ A switch child node has the following optional property:
switch. Must be set if the switch can not detect switch. Must be set if the switch can not detect
the presence and/or size of a connected EEPROM, the presence and/or size of a connected EEPROM,
otherwise optional. otherwise optional.
- reset-gpios : phandle and specifier to a gpio line connected to
reset pin of the switch chip.
A switch may have multiple "port" children nodes A switch may have multiple "port" children nodes
......
...@@ -10,10 +10,17 @@ If you need a stable binding, use the old dsa.txt binding. ...@@ -10,10 +10,17 @@ If you need a stable binding, use the old dsa.txt binding.
Marvell Switches are MDIO devices. The following properties should be Marvell Switches are MDIO devices. The following properties should be
placed as a child node of an mdio device. placed as a child node of an mdio device.
The properties described here are those specific to Marvell devices.
Additional required and optional properties can be found in dsa.txt.
Required properties: Required properties:
- compatible : Should be one of "marvell,mv88e6085", - compatible : Should be one of "marvell,mv88e6085",
- reg : Address on the MII bus for the switch. - reg : Address on the MII bus for the switch.
Optional properties:
- reset-gpios : Should be a gpio specifier for a reset line
Example: Example:
mdio { mdio {
...@@ -23,5 +30,6 @@ Example: ...@@ -23,5 +30,6 @@ Example:
switch0: switch@0 { switch0: switch@0 {
compatible = "marvell,mv88e6085"; compatible = "marvell,mv88e6085";
reg = <0>; reg = <0>;
reset-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>;
}; };
}; };
...@@ -2582,7 +2582,7 @@ static int mv88e6xxx_switch_reset(struct mv88e6xxx_priv_state *ps) ...@@ -2582,7 +2582,7 @@ static int mv88e6xxx_switch_reset(struct mv88e6xxx_priv_state *ps)
{ {
bool ppu_active = mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU_ACTIVE); bool ppu_active = mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU_ACTIVE);
u16 is_reset = (ppu_active ? 0x8800 : 0xc800); u16 is_reset = (ppu_active ? 0x8800 : 0xc800);
struct gpio_desc *gpiod = ps->ds->pd->reset; struct gpio_desc *gpiod = ps->reset;
unsigned long timeout; unsigned long timeout;
int ret; int ret;
int i; int i;
...@@ -3634,6 +3634,7 @@ int mv88e6xxx_probe(struct mdio_device *mdiodev) ...@@ -3634,6 +3634,7 @@ int mv88e6xxx_probe(struct mdio_device *mdiodev)
struct mv88e6xxx_priv_state *ps; struct mv88e6xxx_priv_state *ps;
int id, prod_num, rev; int id, prod_num, rev;
struct dsa_switch *ds; struct dsa_switch *ds;
int err;
ds = devm_kzalloc(dev, sizeof(*ds) + sizeof(*ps), GFP_KERNEL); ds = devm_kzalloc(dev, sizeof(*ds) + sizeof(*ps), GFP_KERNEL);
if (!ds) if (!ds)
...@@ -3663,6 +3664,17 @@ int mv88e6xxx_probe(struct mdio_device *mdiodev) ...@@ -3663,6 +3664,17 @@ int mv88e6xxx_probe(struct mdio_device *mdiodev)
if (!ps->info) if (!ps->info)
return -ENODEV; return -ENODEV;
ps->reset = devm_gpiod_get(&mdiodev->dev, "reset", GPIOD_ASIS);
if (IS_ERR(ps->reset)) {
err = PTR_ERR(ps->reset);
if (err == -ENOENT) {
/* Optional, so not an error */
ps->reset = NULL;
} else {
return err;
}
}
dev_set_drvdata(dev, ds); dev_set_drvdata(dev, ds);
dev_info(dev, "switch 0x%x probed: %s, revision %u\n", dev_info(dev, "switch 0x%x probed: %s, revision %u\n",
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define __MV88E6XXX_H #define __MV88E6XXX_H
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include <linux/gpio/consumer.h>
#ifndef UINT64_MAX #ifndef UINT64_MAX
#define UINT64_MAX (u64)(~((u64)0)) #define UINT64_MAX (u64)(~((u64)0))
...@@ -595,6 +596,12 @@ struct mv88e6xxx_priv_state { ...@@ -595,6 +596,12 @@ struct mv88e6xxx_priv_state {
DECLARE_BITMAP(port_state_update_mask, DSA_MAX_PORTS); DECLARE_BITMAP(port_state_update_mask, DSA_MAX_PORTS);
struct work_struct bridge_work; struct work_struct bridge_work;
/* A switch may have a GPIO line tied to its reset pin. Parse
* this from the device tree, and use it before performing
* switch soft reset.
*/
struct gpio_desc *reset;
}; };
enum stat_type { enum stat_type {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/phy_fixed.h> #include <linux/phy_fixed.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
...@@ -65,13 +64,6 @@ struct dsa_chip_data { ...@@ -65,13 +64,6 @@ struct dsa_chip_data {
* NULL if there is only one switch chip. * NULL if there is only one switch chip.
*/ */
s8 *rtable; s8 *rtable;
/*
* A switch may have a GPIO line tied to its reset pin. Parse
* this from the device tree, and use it before performing
* switch soft reset.
*/
struct gpio_desc *reset;
}; };
struct dsa_platform_data { struct dsa_platform_data {
......
...@@ -659,9 +659,6 @@ static int dsa_of_probe(struct device *dev) ...@@ -659,9 +659,6 @@ static int dsa_of_probe(struct device *dev)
const char *port_name; const char *port_name;
int chip_index, port_index; int chip_index, port_index;
const unsigned int *sw_addr, *port_reg; const unsigned int *sw_addr, *port_reg;
int gpio;
enum of_gpio_flags of_flags;
unsigned long flags;
u32 eeprom_len; u32 eeprom_len;
int ret; int ret;
...@@ -740,19 +737,6 @@ static int dsa_of_probe(struct device *dev) ...@@ -740,19 +737,6 @@ static int dsa_of_probe(struct device *dev)
put_device(cd->host_dev); put_device(cd->host_dev);
cd->host_dev = &mdio_bus_switch->dev; cd->host_dev = &mdio_bus_switch->dev;
} }
gpio = of_get_named_gpio_flags(child, "reset-gpios", 0,
&of_flags);
if (gpio_is_valid(gpio)) {
flags = (of_flags == OF_GPIO_ACTIVE_LOW ?
GPIOF_ACTIVE_LOW : 0);
ret = devm_gpio_request_one(dev, gpio, flags,
"switch_reset");
if (ret)
goto out_free_chip;
cd->reset = gpio_to_desc(gpio);
gpiod_direction_output(cd->reset, 0);
}
for_each_available_child_of_node(child, port) { for_each_available_child_of_node(child, port) {
port_reg = of_get_property(port, "reg", NULL); port_reg = of_get_property(port, "reg", NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment