generic: rtl836x: add hw_reset field to struct rtl8366_smi
authorGabor Juhos <juhosg@openwrt.org>
Thu, 2 Aug 2012 09:54:21 +0000 (09:54 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Thu, 2 Aug 2012 09:54:21 +0000 (09:54 +0000)
It will be used to start/stop the switch if that is
supported by the given board.

SVN-Revision: 32943

target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
target/linux/generic/files/drivers/net/phy/rtl8366rb.c
target/linux/generic/files/drivers/net/phy/rtl8366s.c
target/linux/generic/files/drivers/net/phy/rtl8367.c
target/linux/generic/files/include/linux/rtl8366.h
target/linux/generic/files/include/linux/rtl8367.h

index 1288db1982efc0eb271f5362507e37f0a9d03ac0..9903269390e452a5279db68b8ab3ee029eb630bd 100644 (file)
@@ -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;
 
index ea5e6dbd6c8a0c9da62848863d8cec6edca4e553..700f83c1a545ffa88055edbebd05d0ca59743697 100644 (file)
@@ -32,6 +32,7 @@ struct rtl8366_smi {
        struct device           *parent;
        unsigned int            gpio_sda;
        unsigned int            gpio_sck;
+       void                    (*hw_reset)(bool active);
        unsigned int            clk_delay;      /* ns */
        u8                      cmd_read;
        u8                      cmd_write;
index 3901602f93e684d79a8cb3e25f208382909e3981..775949792d74251d475366235d2e0a65edc98c20 100644 (file)
@@ -1194,6 +1194,8 @@ static int __devinit rtl8366rb_probe(struct platform_device *pdev)
 
        smi->gpio_sda = pdata->gpio_sda;
        smi->gpio_sck = pdata->gpio_sck;
+       smi->hw_reset = pdata->hw_reset;
+
        smi->clk_delay = 10;
        smi->cmd_read = 0xa9;
        smi->cmd_write = 0xa8;
index 21f743926ac6e8d3d605bbcc73d3b1a9386ee00b..77427d6c9e3da89274090af5d008a65db6495fec 100644 (file)
@@ -1074,6 +1074,8 @@ static int __devinit rtl8366s_probe(struct platform_device *pdev)
 
        smi->gpio_sda = pdata->gpio_sda;
        smi->gpio_sck = pdata->gpio_sck;
+       smi->hw_reset = pdata->hw_reset;
+
        smi->clk_delay = 10;
        smi->cmd_read = 0xa9;
        smi->cmd_write = 0xa8;
index 4f2ba6327baa3d1b8c256d819718231d13e30c22..ee2a04701304503a4b09c473231ca6361d534581 100644 (file)
@@ -1692,6 +1692,8 @@ static int __devinit rtl8367_probe(struct platform_device *pdev)
 
        smi->gpio_sda = pdata->gpio_sda;
        smi->gpio_sck = pdata->gpio_sck;
+       smi->hw_reset = pdata->hw_reset;
+
        smi->clk_delay = 1500;
        smi->cmd_read = 0xb9;
        smi->cmd_write = 0xb8;
index 22ce614d404d1e972c69cde98bfd3e5d26ba477d..78daed22057540c785c071398f1ee9a073478aa1 100644 (file)
@@ -29,6 +29,8 @@ struct rtl8366_initval {
 struct rtl8366_platform_data {
        unsigned        gpio_sda;
        unsigned        gpio_sck;
+       void            (*hw_reset)(bool active);
+
        unsigned        num_initvals;
        struct rtl8366_initval *initvals;
 };
index aab553e229fb88adda414d25f3c4b5734bdd0e7d..470c5f38122d23da1dbe2871a5f966ce3eeed9b2 100644 (file)
@@ -50,6 +50,7 @@ struct rtl8367_extif_config {
 struct rtl8367_platform_data {
        unsigned gpio_sda;
        unsigned gpio_sck;
+       void (*hw_reset)(bool active);
 
        struct rtl8367_extif_config *extif0_cfg;
        struct rtl8367_extif_config *extif1_cfg;