Skip to content

Commit 52638f7

Browse files
lunndavem330
authored andcommitted
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: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 14c7b3c commit 52638f7

File tree

6 files changed

+28
-27
lines changed

6 files changed

+28
-27
lines changed

Documentation/devicetree/bindings/net/dsa/dsa.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ A switch child node has the following optional property:
3131
switch. Must be set if the switch can not detect
3232
the presence and/or size of a connected EEPROM,
3333
otherwise optional.
34-
- reset-gpios : phandle and specifier to a gpio line connected to
35-
reset pin of the switch chip.
3634

3735
A switch may have multiple "port" children nodes
3836

Documentation/devicetree/bindings/net/dsa/marvell.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@ If you need a stable binding, use the old dsa.txt binding.
1010
Marvell Switches are MDIO devices. The following properties should be
1111
placed as a child node of an mdio device.
1212

13+
The properties described here are those specific to Marvell devices.
14+
Additional required and optional properties can be found in dsa.txt.
15+
1316
Required properties:
1417
- compatible : Should be one of "marvell,mv88e6085",
1518
- reg : Address on the MII bus for the switch.
1619

20+
Optional properties:
21+
22+
- reset-gpios : Should be a gpio specifier for a reset line
23+
1724
Example:
1825

1926
mdio {
@@ -23,5 +30,6 @@ Example:
2330
switch0: switch@0 {
2431
compatible = "marvell,mv88e6085";
2532
reg = <0>;
33+
reset-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>;
2634
};
2735
};

drivers/net/dsa/mv88e6xxx.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2582,7 +2582,7 @@ static int mv88e6xxx_switch_reset(struct mv88e6xxx_priv_state *ps)
25822582
{
25832583
bool ppu_active = mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU_ACTIVE);
25842584
u16 is_reset = (ppu_active ? 0x8800 : 0xc800);
2585-
struct gpio_desc *gpiod = ps->ds->pd->reset;
2585+
struct gpio_desc *gpiod = ps->reset;
25862586
unsigned long timeout;
25872587
int ret;
25882588
int i;
@@ -3634,6 +3634,7 @@ int mv88e6xxx_probe(struct mdio_device *mdiodev)
36343634
struct mv88e6xxx_priv_state *ps;
36353635
int id, prod_num, rev;
36363636
struct dsa_switch *ds;
3637+
int err;
36373638

36383639
ds = devm_kzalloc(dev, sizeof(*ds) + sizeof(*ps), GFP_KERNEL);
36393640
if (!ds)
@@ -3663,6 +3664,17 @@ int mv88e6xxx_probe(struct mdio_device *mdiodev)
36633664
if (!ps->info)
36643665
return -ENODEV;
36653666

3667+
ps->reset = devm_gpiod_get(&mdiodev->dev, "reset", GPIOD_ASIS);
3668+
if (IS_ERR(ps->reset)) {
3669+
err = PTR_ERR(ps->reset);
3670+
if (err == -ENOENT) {
3671+
/* Optional, so not an error */
3672+
ps->reset = NULL;
3673+
} else {
3674+
return err;
3675+
}
3676+
}
3677+
36663678
dev_set_drvdata(dev, ds);
36673679

36683680
dev_info(dev, "switch 0x%x probed: %s, revision %u\n",

drivers/net/dsa/mv88e6xxx.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define __MV88E6XXX_H
1313

1414
#include <linux/if_vlan.h>
15+
#include <linux/gpio/consumer.h>
1516

1617
#ifndef UINT64_MAX
1718
#define UINT64_MAX (u64)(~((u64)0))
@@ -595,6 +596,12 @@ struct mv88e6xxx_priv_state {
595596
DECLARE_BITMAP(port_state_update_mask, DSA_MAX_PORTS);
596597

597598
struct work_struct bridge_work;
599+
600+
/* A switch may have a GPIO line tied to its reset pin. Parse
601+
* this from the device tree, and use it before performing
602+
* switch soft reset.
603+
*/
604+
struct gpio_desc *reset;
598605
};
599606

600607
enum stat_type {

include/net/dsa.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <linux/timer.h>
1717
#include <linux/workqueue.h>
1818
#include <linux/of.h>
19-
#include <linux/of_gpio.h>
2019
#include <linux/phy.h>
2120
#include <linux/phy_fixed.h>
2221
#include <linux/ethtool.h>
@@ -65,13 +64,6 @@ struct dsa_chip_data {
6564
* NULL if there is only one switch chip.
6665
*/
6766
s8 *rtable;
68-
69-
/*
70-
* A switch may have a GPIO line tied to its reset pin. Parse
71-
* this from the device tree, and use it before performing
72-
* switch soft reset.
73-
*/
74-
struct gpio_desc *reset;
7567
};
7668

7769
struct dsa_platform_data {

net/dsa/dsa.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,6 @@ static int dsa_of_probe(struct device *dev)
659659
const char *port_name;
660660
int chip_index, port_index;
661661
const unsigned int *sw_addr, *port_reg;
662-
int gpio;
663-
enum of_gpio_flags of_flags;
664-
unsigned long flags;
665662
u32 eeprom_len;
666663
int ret;
667664

@@ -740,19 +737,6 @@ static int dsa_of_probe(struct device *dev)
740737
put_device(cd->host_dev);
741738
cd->host_dev = &mdio_bus_switch->dev;
742739
}
743-
gpio = of_get_named_gpio_flags(child, "reset-gpios", 0,
744-
&of_flags);
745-
if (gpio_is_valid(gpio)) {
746-
flags = (of_flags == OF_GPIO_ACTIVE_LOW ?
747-
GPIOF_ACTIVE_LOW : 0);
748-
ret = devm_gpio_request_one(dev, gpio, flags,
749-
"switch_reset");
750-
if (ret)
751-
goto out_free_chip;
752-
753-
cd->reset = gpio_to_desc(gpio);
754-
gpiod_direction_output(cd->reset, 0);
755-
}
756740

757741
for_each_available_child_of_node(child, port) {
758742
port_reg = of_get_property(port, "reg", NULL);

0 commit comments

Comments
 (0)