Commit 1e997d04 authored by David S. Miller's avatar David S. Miller

Merge branch 'dsa-realtek-next'

Luiz Angelo Daros de Luca says:

====================
net: dsa: realtek: realtek-mdio: reset before setup

This patch series cleans the realtek-smi reset code and copy that to the
realtek-mdio.

v1-v2)
- do not run reset code block if GPIO is missing. It was printing "RESET
  deasserted" even when there is no GPIO configured.
- reset switch after dsa_unregister_switch()
- demote reset messages to debug

v2-v3)
- do not assert the reset on gpiod_get. Do it explicitly aferwards.
- split the commit into two (one for each module)
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents dd263a8c 05f7b042
...@@ -152,6 +152,21 @@ static int realtek_mdio_probe(struct mdio_device *mdiodev) ...@@ -152,6 +152,21 @@ static int realtek_mdio_probe(struct mdio_device *mdiodev)
/* TODO: if power is software controlled, set up any regulators here */ /* TODO: if power is software controlled, set up any regulators here */
priv->leds_disabled = of_property_read_bool(np, "realtek,disable-leds"); priv->leds_disabled = of_property_read_bool(np, "realtek,disable-leds");
priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(priv->reset)) {
dev_err(dev, "failed to get RESET GPIO\n");
return PTR_ERR(priv->reset);
}
if (priv->reset) {
gpiod_set_value(priv->reset, 1);
dev_dbg(dev, "asserted RESET\n");
msleep(REALTEK_HW_STOP_DELAY);
gpiod_set_value(priv->reset, 0);
msleep(REALTEK_HW_START_DELAY);
dev_dbg(dev, "deasserted RESET\n");
}
ret = priv->ops->detect(priv); ret = priv->ops->detect(priv);
if (ret) { if (ret) {
dev_err(dev, "unable to detect switch\n"); dev_err(dev, "unable to detect switch\n");
...@@ -185,6 +200,10 @@ static void realtek_mdio_remove(struct mdio_device *mdiodev) ...@@ -185,6 +200,10 @@ static void realtek_mdio_remove(struct mdio_device *mdiodev)
dsa_unregister_switch(priv->ds); dsa_unregister_switch(priv->ds);
/* leave the device reset asserted */
if (priv->reset)
gpiod_set_value(priv->reset, 1);
dev_set_drvdata(&mdiodev->dev, NULL); dev_set_drvdata(&mdiodev->dev, NULL);
} }
......
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
#include "realtek.h" #include "realtek.h"
#define REALTEK_SMI_ACK_RETRY_COUNT 5 #define REALTEK_SMI_ACK_RETRY_COUNT 5
#define REALTEK_SMI_HW_STOP_DELAY 25 /* msecs */
#define REALTEK_SMI_HW_START_DELAY 100 /* msecs */
static inline void realtek_smi_clk_delay(struct realtek_priv *priv) static inline void realtek_smi_clk_delay(struct realtek_priv *priv)
{ {
...@@ -420,16 +418,19 @@ static int realtek_smi_probe(struct platform_device *pdev) ...@@ -420,16 +418,19 @@ static int realtek_smi_probe(struct platform_device *pdev)
/* TODO: if power is software controlled, set up any regulators here */ /* TODO: if power is software controlled, set up any regulators here */
/* Assert then deassert RESET */ priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(priv->reset)) { if (IS_ERR(priv->reset)) {
dev_err(dev, "failed to get RESET GPIO\n"); dev_err(dev, "failed to get RESET GPIO\n");
return PTR_ERR(priv->reset); return PTR_ERR(priv->reset);
} }
msleep(REALTEK_SMI_HW_STOP_DELAY); if (priv->reset) {
gpiod_set_value(priv->reset, 1);
dev_dbg(dev, "asserted RESET\n");
msleep(REALTEK_HW_STOP_DELAY);
gpiod_set_value(priv->reset, 0); gpiod_set_value(priv->reset, 0);
msleep(REALTEK_SMI_HW_START_DELAY); msleep(REALTEK_HW_START_DELAY);
dev_info(dev, "deasserted RESET\n"); dev_dbg(dev, "deasserted RESET\n");
}
/* Fetch MDIO pins */ /* Fetch MDIO pins */
priv->mdc = devm_gpiod_get_optional(dev, "mdc", GPIOD_OUT_LOW); priv->mdc = devm_gpiod_get_optional(dev, "mdc", GPIOD_OUT_LOW);
...@@ -474,6 +475,9 @@ static int realtek_smi_remove(struct platform_device *pdev) ...@@ -474,6 +475,9 @@ static int realtek_smi_remove(struct platform_device *pdev)
dsa_unregister_switch(priv->ds); dsa_unregister_switch(priv->ds);
if (priv->slave_mii_bus) if (priv->slave_mii_bus)
of_node_put(priv->slave_mii_bus->dev.of_node); of_node_put(priv->slave_mii_bus->dev.of_node);
/* leave the device reset asserted */
if (priv->reset)
gpiod_set_value(priv->reset, 1); gpiod_set_value(priv->reset, 1);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <net/dsa.h> #include <net/dsa.h>
#define REALTEK_HW_STOP_DELAY 25 /* msecs */
#define REALTEK_HW_START_DELAY 100 /* msecs */
struct realtek_ops; struct realtek_ops;
struct dentry; struct dentry;
struct inode; struct inode;
......
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