wmac: add 10m support and solve multicast problem
authorhwg <hwg@rock-chips.com>
Thu, 27 Sep 2012 12:32:05 +0000 (20:32 +0800)
committerhwg <hwg@rock-chips.com>
Thu, 27 Sep 2012 12:37:37 +0000 (20:37 +0800)
arch/arm/mach-rk29/board-rk29-ddr3sdk.c
arch/arm/mach-rk30/board-rk30-sdk-vmac.c [changed mode: 0644->0755]
arch/arm/plat-rk/include/plat/board.h
drivers/net/rk29_vmac.c

index 91fc6b5301cd60fcfa33331328cdb1a9e73474fa..6bc4f213bd3e47ffe4a4b9fe8ad96e7a481fdcb6 100755 (executable)
@@ -2948,6 +2948,18 @@ static struct platform_device *devices[] __initdata = {
  * spi devices
  * author: cmc@rock-chips.com
  *****************************************************************************************/
+
+#define BIT_EMAC_SPEED      (1 << 10)
+static int rk29_vmac_speed_switch(int speed)
+{
+       printk("%s--speed=%d\n", __FUNCTION__, speed);
+       if (10 == speed) {
+            writel(readl(RK29_GRF_BASE + 0xbc) & (~BIT_EMAC_SPEED), RK29_GRF_BASE + 0xbc);
+        } else {
+            writel(readl(RK29_GRF_BASE + 0xbc) | BIT_EMAC_SPEED, RK29_GRF_BASE + 0xbc);
+        }
+} 
 static int rk29_vmac_register_set(void)
 {
        //config rk29 vmac as rmii, 100MHz
old mode 100644 (file)
new mode 100755 (executable)
index 5ec8866..35d4511
@@ -72,9 +72,21 @@ static int rk30_rmii_power_control(int enable)
        return 0;
 }
 
+#define BIT_EMAC_SPEED      (1 << 1)
+static int rk29_vmac_speed_switch(int speed)
+{
+       printk("%s--speed=%d\n", __FUNCTION__, speed);
+       if (10 == speed) {
+           writel_relaxed(readl_relaxed(RK30_GRF_BASE + GRF_SOC_CON1) & (~BIT_EMAC_SPEED), RK30_GRF_BASE + GRF_SOC_CON1);
+       } else {
+           writel_relaxed(readl_relaxed(RK30_GRF_BASE + GRF_SOC_CON1) | ( BIT_EMAC_SPEED), RK30_GRF_BASE + GRF_SOC_CON1);
+       }
+}
+
 struct rk29_vmac_platform_data board_vmac_data = {
        .vmac_register_set = rk30_vmac_register_set,
        .rmii_io_init = rk30_rmii_io_init,
        .rmii_io_deinit = rk30_rmii_io_deinit,
        .rmii_power_control = rk30_rmii_power_control,
+       .rmii_speed_switch = rk29_vmac_speed_switch,
 };
index 4a9c3ce47852ff0c7e78b1cc85e2aa79047c3fae..68cb8fdc9c35f7bb5d5773b683a17719088d6401 100644 (file)
@@ -193,6 +193,7 @@ struct rk29_vmac_platform_data {
        int (*rmii_io_init)(void);
        int (*rmii_io_deinit)(void);
        int (*rmii_power_control)(int enable);
+        int(*rmii_speed_switch)(int speed);
 };
 
 #define BOOT_MODE_NORMAL               0
index 95e79e45e27461277641ea23b67f868fd090ef24..f64bb4e8a5f22ede7588a506d79667eb160fc792 100755 (executable)
@@ -136,6 +136,7 @@ static void vmac_handle_link_change(struct net_device *dev)
        struct phy_device *phydev = ap->phy_dev;\r
        unsigned long flags;\r
        int report_change = 0;\r
+       struct rk29_vmac_platform_data *pdata = ap->pdev->dev.platform_data;\r
 \r
        spin_lock_irqsave(&ap->lock, flags);\r
 \r
@@ -160,6 +161,9 @@ static void vmac_handle_link_change(struct net_device *dev)
                report_change = 1;\r
        }\r
 \r
+       if (pdata && pdata->rmii_speed_switch)\r
+               pdata->rmii_speed_switch(phydev->speed);\r
+\r
        if (phydev->link != ap->link) {\r
                ap->link = phydev->link;\r
                report_change = 1;\r
@@ -1432,10 +1436,10 @@ static void vmac_set_multicast_list(struct net_device *dev)
        spin_lock_irqsave(&ap->lock, flags);\r
 \r
        promisc = !!(dev->flags & IFF_PROMISC);\r
-       reg = vmac_readl(ap, ENABLE);\r
+       reg = vmac_readl(ap, CONTROL);\r
        if (promisc != !!(reg & PROM_MASK)) {\r
                reg ^= PROM_MASK;\r
-               vmac_writel(ap, reg, ENABLE);\r
+               vmac_writel(ap, reg, CONTROL);\r
        }\r
 \r
        if (dev->flags & IFF_ALLMULTI)\r