generic: ar8216: add vtu_load_vlan field to ar8xxx_chip
[openwrt.git] / target / linux / generic / files / drivers / net / phy / ar8216.c
index 485cb52..d514ec7 100644 (file)
@@ -44,6 +44,8 @@ struct ar8xxx_chip {
        void (*setup_port)(struct ar8216_priv *priv, int port, u32 egress,
                           u32 ingress, u32 members, u32 pvid);
        int (*atu_flush)(struct ar8216_priv *priv);
+       void (*vtu_flush)(struct ar8216_priv *priv);
+       void (*vtu_load_vlan)(struct ar8216_priv *priv, u32 vid, u32 port_mask);
 };
 
 struct ar8216_priv {
@@ -482,6 +484,21 @@ ar8216_vtu_op(struct ar8216_priv *priv, u32 op, u32 val)
        priv->write(priv, AR8216_REG_VTU, op);
 }
 
+static void
+ar8216_vtu_flush(struct ar8216_priv *priv)
+{
+       ar8216_vtu_op(priv, AR8216_VTU_OP_FLUSH, 0);
+}
+
+static void
+ar8216_vtu_load_vlan(struct ar8216_priv *priv, u32 vid, u32 port_mask)
+{
+       u32 op;
+
+       op = AR8216_VTU_OP_LOAD | (vid << AR8216_VTU_VID_S);
+       ar8216_vtu_op(priv, op, port_mask);
+}
+
 static int
 ar8216_atu_flush(struct ar8216_priv *priv)
 {
@@ -553,7 +570,7 @@ ar8216_hw_apply(struct switch_dev *dev)
 
        mutex_lock(&priv->reg_mutex);
        /* flush all vlan translation unit entries */
-       ar8216_vtu_op(priv, AR8216_VTU_OP_FLUSH, 0);
+       priv->chip->vtu_flush(priv);
 
        memset(portmask, 0, sizeof(portmask));
        if (!priv->init) {
@@ -571,10 +588,8 @@ ar8216_hw_apply(struct switch_dev *dev)
                                        portmask[i] |= vp & ~mask;
                        }
 
-                       ar8216_vtu_op(priv,
-                               AR8216_VTU_OP_LOAD |
-                               (priv->vlan_id[j] << AR8216_VTU_VID_S),
-                               priv->vlan_table[j]);
+                       priv->chip->vtu_load_vlan(priv, priv->vlan_id[j],
+                                                priv->vlan_table[j]);
                }
        } else {
                /* vlan disabled:
@@ -760,6 +775,8 @@ static const struct ar8xxx_chip ar8216_chip = {
        .init_port = ar8216_init_port,
        .setup_port = ar8216_setup_port,
        .atu_flush = ar8216_atu_flush,
+       .vtu_flush = ar8216_vtu_flush,
+       .vtu_load_vlan = ar8216_vtu_load_vlan,
 };
 
 static const struct ar8xxx_chip ar8236_chip = {
@@ -767,6 +784,8 @@ static const struct ar8xxx_chip ar8236_chip = {
        .init_port = ar8216_init_port,
        .setup_port = ar8236_setup_port,
        .atu_flush = ar8216_atu_flush,
+       .vtu_flush = ar8216_vtu_flush,
+       .vtu_load_vlan = ar8216_vtu_load_vlan,
 };
 
 static const struct ar8xxx_chip ar8316_chip = {
@@ -774,6 +793,8 @@ static const struct ar8xxx_chip ar8316_chip = {
        .init_port = ar8216_init_port,
        .setup_port = ar8216_setup_port,
        .atu_flush = ar8216_atu_flush,
+       .vtu_flush = ar8216_vtu_flush,
+       .vtu_load_vlan = ar8216_vtu_load_vlan,
 };
 
 static int