summaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-08-02 09:54:21 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-08-02 09:54:21 +0000
commite2782eae8ee17143d0506078fcf5c0a44b2302fe (patch)
tree45308fcc32ba873080939113a3dfdbae0581eb9d /target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
parent614ca3cc9e73024b8eba81a414b34c700d8d42ca (diff)
downloadmaster-31e0f0ae-e2782eae8ee17143d0506078fcf5c0a44b2302fe.tar.gz
master-31e0f0ae-e2782eae8ee17143d0506078fcf5c0a44b2302fe.tar.bz2
master-31e0f0ae-e2782eae8ee17143d0506078fcf5c0a44b2302fe.zip
generic: rtl836x: add hw_reset field to struct rtl8366_smi
It will be used to start/stop the switch if that is supported by the given board. SVN-Revision: 32943
Diffstat (limited to 'target/linux/generic/files/drivers/net/phy/rtl8366_smi.c')
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366_smi.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
index 1288db1982..9903269390 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
@@ -308,6 +308,19 @@ int rtl8366_smi_rmwr(struct rtl8366_smi *smi, u32 addr, u32 mask, u32 data)
}
EXPORT_SYMBOL_GPL(rtl8366_smi_rmwr);
+static int rtl8366_reset(struct rtl8366_smi *smi)
+{
+ if (smi->hw_reset) {
+ smi->hw_reset(true);
+ msleep(25);
+ smi->hw_reset(false);
+ msleep(25);
+ return 0;
+ }
+
+ return smi->ops->reset_chip(smi);
+}
+
static int rtl8366_mc_is_used(struct rtl8366_smi *smi, int mc_index, int *used)
{
int err;
@@ -938,7 +951,7 @@ int rtl8366_sw_reset_switch(struct switch_dev *dev)
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
int err;
- err = smi->ops->reset_chip(smi);
+ err = rtl8366_reset(smi);
if (err)
return err;
@@ -1227,6 +1240,13 @@ static int __rtl8366_smi_init(struct rtl8366_smi *smi, const char *name)
}
spin_lock_init(&smi->lock);
+
+ /* start the switch */
+ if (smi->hw_reset) {
+ smi->hw_reset(false);
+ msleep(25);
+ }
+
return 0;
err_free_sda:
@@ -1237,6 +1257,9 @@ static int __rtl8366_smi_init(struct rtl8366_smi *smi, const char *name)
static void __rtl8366_smi_cleanup(struct rtl8366_smi *smi)
{
+ if (smi->hw_reset)
+ smi->hw_reset(true);
+
gpio_free(smi->gpio_sck);
gpio_free(smi->gpio_sda);
}
@@ -1300,7 +1323,7 @@ int rtl8366_smi_init(struct rtl8366_smi *smi)
goto err_free_sck;
}
- err = smi->ops->reset_chip(smi);
+ err = rtl8366_reset(smi);
if (err)
goto err_free_sck;