diff options
| author | Marek Vasut <marex@denx.de> | 2018-12-10 08:43:06 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2018-12-10 15:07:56 -0500 |
| commit | 924352c3d6347d96528cebcef9461cebe928c117 (patch) | |
| tree | a89b500b359e10fed23a61c28c65b373d0aac7c9 /drivers/net/dsa/microchip | |
| parent | a324d6e454aa986d64cb650caa8ed7150023b3f3 (diff) | |
net: dsa: ksz: Add reset GPIO handling
Add code to handle optional reset GPIO in the KSZ switch driver. The switch
has a reset GPIO line which can be controlled by the CPU, so make sure it is
configured correctly in such setups.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: Woojung Huh <woojung.huh@microchip.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Tristram Ha <Tristram.Ha@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa/microchip')
| -rw-r--r-- | drivers/net/dsa/microchip/ksz_common.c | 17 | ||||
| -rw-r--r-- | drivers/net/dsa/microchip/ksz_priv.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 9705808c3af7..3b12e2dcff31 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c | |||
| @@ -8,12 +8,14 @@ | |||
| 8 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
| 9 | #include <linux/export.h> | 9 | #include <linux/export.h> |
| 10 | #include <linux/gpio.h> | 10 | #include <linux/gpio.h> |
| 11 | #include <linux/gpio/consumer.h> | ||
| 11 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
| 12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 13 | #include <linux/platform_data/microchip-ksz.h> | 14 | #include <linux/platform_data/microchip-ksz.h> |
| 14 | #include <linux/phy.h> | 15 | #include <linux/phy.h> |
| 15 | #include <linux/etherdevice.h> | 16 | #include <linux/etherdevice.h> |
| 16 | #include <linux/if_bridge.h> | 17 | #include <linux/if_bridge.h> |
| 18 | #include <linux/of_gpio.h> | ||
| 17 | #include <linux/of_net.h> | 19 | #include <linux/of_net.h> |
| 18 | #include <net/dsa.h> | 20 | #include <net/dsa.h> |
| 19 | #include <net/switchdev.h> | 21 | #include <net/switchdev.h> |
| @@ -294,6 +296,17 @@ int ksz_switch_register(struct ksz_device *dev, | |||
| 294 | if (dev->pdata) | 296 | if (dev->pdata) |
| 295 | dev->chip_id = dev->pdata->chip_id; | 297 | dev->chip_id = dev->pdata->chip_id; |
| 296 | 298 | ||
| 299 | dev->reset_gpio = devm_gpiod_get_optional(dev->dev, "reset", | ||
| 300 | GPIOD_OUT_LOW); | ||
| 301 | if (IS_ERR(dev->reset_gpio)) | ||
| 302 | return PTR_ERR(dev->reset_gpio); | ||
| 303 | |||
| 304 | if (dev->reset_gpio) { | ||
| 305 | gpiod_set_value(dev->reset_gpio, 1); | ||
| 306 | mdelay(10); | ||
| 307 | gpiod_set_value(dev->reset_gpio, 0); | ||
| 308 | } | ||
| 309 | |||
| 297 | mutex_init(&dev->reg_mutex); | 310 | mutex_init(&dev->reg_mutex); |
| 298 | mutex_init(&dev->stats_mutex); | 311 | mutex_init(&dev->stats_mutex); |
| 299 | mutex_init(&dev->alu_mutex); | 312 | mutex_init(&dev->alu_mutex); |
| @@ -329,6 +342,10 @@ void ksz_switch_remove(struct ksz_device *dev) | |||
| 329 | { | 342 | { |
| 330 | dev->dev_ops->exit(dev); | 343 | dev->dev_ops->exit(dev); |
| 331 | dsa_unregister_switch(dev->ds); | 344 | dsa_unregister_switch(dev->ds); |
| 345 | |||
| 346 | if (dev->reset_gpio) | ||
| 347 | gpiod_set_value(dev->reset_gpio, 1); | ||
| 348 | |||
| 332 | } | 349 | } |
| 333 | EXPORT_SYMBOL(ksz_switch_remove); | 350 | EXPORT_SYMBOL(ksz_switch_remove); |
| 334 | 351 | ||
diff --git a/drivers/net/dsa/microchip/ksz_priv.h b/drivers/net/dsa/microchip/ksz_priv.h index a38ff0841ed4..60b49010904b 100644 --- a/drivers/net/dsa/microchip/ksz_priv.h +++ b/drivers/net/dsa/microchip/ksz_priv.h | |||
| @@ -59,6 +59,8 @@ struct ksz_device { | |||
| 59 | 59 | ||
| 60 | void *priv; | 60 | void *priv; |
| 61 | 61 | ||
| 62 | struct gpio_desc *reset_gpio; /* Optional reset GPIO */ | ||
| 63 | |||
| 62 | /* chip specific data */ | 64 | /* chip specific data */ |
| 63 | u32 chip_id; | 65 | u32 chip_id; |
| 64 | int num_vlans; | 66 | int num_vlans; |
