ar71xx: remove dead code
[openwrt.git] / target / linux / ar71xx / files / drivers / net / ag71xx / ag71xx_ar7240.c
index 1bc7f58..8e15849 100644 (file)
 #define   AR7240_VTUDATA_MEMBER                BITS(0, 10)
 #define   AR7240_VTUDATA_VALID         BIT(11)
 
+#define AR7240_REG_ATU                 0x50
+#define AR7240_ATU_FLUSH_ALL           0x1
+
 #define AR7240_REG_AT_CTRL             0x5c
+#define AR7240_AT_CTRL_AGE_TIME                BITS(0, 15)
+#define AR7240_AT_CTRL_AGE_EN          BIT(17)
+#define AR7240_AT_CTRL_LEARN_CHANGE    BIT(18)
 #define AR7240_AT_CTRL_ARP_EN          BIT(20)
 
 #define AR7240_REG_TAG_PRIORITY                0x70
@@ -391,49 +397,12 @@ int ar7240sw_phy_write(struct mii_bus *mii, unsigned phy_addr,
        return ret;
 }
 
-static int ar7240sw_capture_stats(struct ar7240sw *as)
-{
-       struct mii_bus *mii = as->mii_bus;
-       int ret;
-
-       /* Capture the hardware statistics for all ports */
-       ar7240sw_reg_write(mii, AR7240_REG_MIB_FUNCTION0,
-                          (AR7240_MIB_FUNC_CAPTURE << AR7240_MIB_FUNC_S));
-
-       /* Wait for the capturing to complete. */
-       ret = ar7240sw_reg_wait(mii, AR7240_REG_MIB_FUNCTION0,
-                               AR7240_MIB_BUSY, 0, 10);
-       return ret;
-}
-
 static void ar7240sw_disable_port(struct ar7240sw *as, unsigned port)
 {
        ar7240sw_reg_write(as->mii_bus, AR7240_REG_PORT_CTRL(port),
                           AR7240_PORT_CTRL_STATE_DISABLED);
 }
 
-static int ar7240sw_reset(struct ar7240sw *as)
-{
-       struct mii_bus *mii = as->mii_bus;
-       int ret;
-       int i;
-
-       /* Set all ports to disabled state. */
-       for (i = 0; i < AR7240_NUM_PORTS; i++)
-               ar7240sw_disable_port(as, i);
-
-       /* Wait for transmit queues to drain. */
-       msleep(2);
-
-       /* Reset the switch. */
-       ar7240sw_reg_write(mii, AR7240_REG_MASK_CTRL,
-                          AR7240_MASK_CTRL_SOFT_RESET);
-
-       ret = ar7240sw_reg_wait(mii, AR7240_REG_MASK_CTRL,
-                               AR7240_MASK_CTRL_SOFT_RESET, 0, 1000);
-       return ret;
-}
-
 static void ar7240sw_setup(struct ar7240sw *as)
 {
        struct mii_bus *mii = as->mii_bus;
@@ -446,8 +415,12 @@ static void ar7240sw_setup(struct ar7240sw *as)
        /* Setup TAG priority mapping */
        ar7240sw_reg_write(mii, AR7240_REG_TAG_PRIORITY, 0xfa50);
 
-       /* Enable ARP frame acknowledge */
-       ar7240sw_reg_set(mii, AR7240_REG_AT_CTRL, AR7240_AT_CTRL_ARP_EN);
+       /* Enable ARP frame acknowledge, aging, MAC replacing */
+       ar7240sw_reg_write(mii, AR7240_REG_AT_CTRL,
+               0x2b /* 5 min age time */ |
+               AR7240_AT_CTRL_AGE_EN |
+               AR7240_AT_CTRL_ARP_EN |
+               AR7240_AT_CTRL_LEARN_CHANGE);
 
        /* Enable Broadcast frames transmitted to the CPU */
        ar7240sw_reg_set(mii, AR7240_REG_FLOOD_MASK,
@@ -461,11 +434,34 @@ static void ar7240sw_setup(struct ar7240sw *as)
        ar7240sw_reg_rmw(mii, AR7240_REG_SERVICE_TAG, AR7240_SERVICE_TAG_M, 0);
 }
 
+static int ar7240sw_reset(struct ar7240sw *as)
+{
+       struct mii_bus *mii = as->mii_bus;
+       int ret;
+       int i;
+
+       /* Set all ports to disabled state. */
+       for (i = 0; i < AR7240_NUM_PORTS; i++)
+               ar7240sw_disable_port(as, i);
+
+       /* Wait for transmit queues to drain. */
+       msleep(2);
+
+       /* Reset the switch. */
+       ar7240sw_reg_write(mii, AR7240_REG_MASK_CTRL,
+                          AR7240_MASK_CTRL_SOFT_RESET);
+
+       ret = ar7240sw_reg_wait(mii, AR7240_REG_MASK_CTRL,
+                               AR7240_MASK_CTRL_SOFT_RESET, 0, 1000);
+
+       ar7240sw_setup(as);
+       return ret;
+}
+
 static void ar7240sw_setup_port(struct ar7240sw *as, unsigned port, u8 portmask)
 {
        struct mii_bus *mii = as->mii_bus;
        u32 ctrl;
-       u32 dest_ports;
        u32 vlan;
 
        ctrl = AR7240_PORT_CTRL_STATE_FORWARD | AR7240_PORT_CTRL_LEARN |
@@ -513,7 +509,7 @@ static void ar7240sw_setup_port(struct ar7240sw *as, unsigned port, u8 portmask)
        /* allow the port to talk to all other ports, but exclude its
         * own ID to prevent frames from being reflected back to the
         * port that they came from */
-       dest_ports = AR7240_PORT_MASK_BUT(port);
+       portmask &= AR7240_PORT_MASK_BUT(port);
 
        /* set default VID and and destination ports for this VLAN */
        vlan |= (portmask << AR7240_PORT_VLAN_DEST_PORTS_S);
@@ -828,23 +824,48 @@ static struct ar7240sw *ar7240_probe(struct ag71xx *ag)
        return as;
 }
 
+static void link_function(struct work_struct *work) {
+       struct ag71xx *ag = container_of(work, struct ag71xx, link_work.work);
+       unsigned long flags;
+       int i;
+       int status = 0;
+
+       for (i = 0; i < 4; i++) {
+               int link = ar7240sw_phy_read(ag->mii_bus, i, MII_BMSR);
+               if(link & BMSR_LSTATUS) {
+                       status = 1;
+                       break;
+               }
+       }
+
+       spin_lock_irqsave(&ag->lock, flags);
+       if(status != ag->link) {
+               ag->link = status;
+               ag71xx_link_adjust(ag);
+       }
+       spin_unlock_irqrestore(&ag->lock, flags);
+
+       schedule_delayed_work(&ag->link_work, HZ / 2);
+}
+
 void ag71xx_ar7240_start(struct ag71xx *ag)
 {
        struct ar7240sw *as = ag->phy_priv;
 
        ar7240sw_reset(as);
-       ar7240sw_setup(as);
 
        ag->speed = SPEED_1000;
-       ag->link = 1;
        ag->duplex = 1;
 
        ar7240_set_addr(as, ag->dev->dev_addr);
        ar7240_hw_apply(&as->swdev);
+
+       schedule_delayed_work(&ag->link_work, HZ / 10);
 }
 
 void ag71xx_ar7240_stop(struct ag71xx *ag)
 {
+       cancel_delayed_work_sync(&ag->link_work);
 }
 
 int __devinit ag71xx_ar7240_init(struct ag71xx *ag)
@@ -858,6 +879,8 @@ int __devinit ag71xx_ar7240_init(struct ag71xx *ag)
        ag->phy_priv = as;
        ar7240sw_reset(as);
 
+       INIT_DELAYED_WORK(&ag->link_work, link_function);
+
        return 0;
 }
 
This page took 0.028262 seconds and 4 git commands to generate.