]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: microchip: add P_STP_CTRL to ksz_chip_reg
authorArun Ramadoss <arun.ramadoss@microchip.com>
Tue, 28 Jun 2022 17:13:28 +0000 (22:43 +0530)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 Jun 2022 12:47:59 +0000 (13:47 +0100)
This patch moves the stp_ctrl_reg from the ksz_chip_data to ksz_chip_reg
structure.

Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/microchip/ksz8795.c
drivers/net/dsa/microchip/ksz8795_reg.h
drivers/net/dsa/microchip/ksz9477.c
drivers/net/dsa/microchip/ksz9477_reg.h
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/ksz_common.h

index 264c960f715d1be436c621dfdeda53b0a68d8eda..911aace4228487bc4704f1895846ef90b0245a8c 100644 (file)
@@ -809,6 +809,9 @@ void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port)
        u8 learn[DSA_MAX_PORTS];
        int first, index, cnt;
        struct ksz_port *p;
+       const u16 *regs;
+
+       regs = dev->info->regs;
 
        if ((uint)port < dev->info->port_cnt) {
                first = port;
@@ -822,9 +825,9 @@ void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port)
                p = &dev->ports[index];
                if (!p->on)
                        continue;
-               ksz_pread8(dev, index, P_STP_CTRL, &learn[index]);
+               ksz_pread8(dev, index, regs[P_STP_CTRL], &learn[index]);
                if (!(learn[index] & PORT_LEARN_DISABLE))
-                       ksz_pwrite8(dev, index, P_STP_CTRL,
+                       ksz_pwrite8(dev, index, regs[P_STP_CTRL],
                                    learn[index] | PORT_LEARN_DISABLE);
        }
        ksz_cfg(dev, S_FLUSH_TABLE_CTRL, SW_FLUSH_DYN_MAC_TABLE, true);
@@ -833,7 +836,7 @@ void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port)
                if (!p->on)
                        continue;
                if (!(learn[index] & PORT_LEARN_DISABLE))
-                       ksz_pwrite8(dev, index, P_STP_CTRL, learn[index]);
+                       ksz_pwrite8(dev, index, regs[P_STP_CTRL], learn[index]);
        }
 }
 
@@ -1236,11 +1239,11 @@ void ksz8_config_cpu_port(struct dsa_switch *ds)
                                p->fiber = 1;
                }
                if (p->fiber)
-                       ksz_port_cfg(dev, i, P_STP_CTRL, PORT_FORCE_FLOW_CTRL,
-                                    true);
+                       ksz_port_cfg(dev, i, regs[P_STP_CTRL],
+                                    PORT_FORCE_FLOW_CTRL, true);
                else
-                       ksz_port_cfg(dev, i, P_STP_CTRL, PORT_FORCE_FLOW_CTRL,
-                                    false);
+                       ksz_port_cfg(dev, i, regs[P_STP_CTRL],
+                                    PORT_FORCE_FLOW_CTRL, false);
        }
 }
 
index 32d985296520ea9414b029629c5df032a6ffd7d7..a848eb4c54cb50c1d02f049053ac3a2bdcbe3616 100644 (file)
 #define P_TAG_CTRL                     REG_PORT_CTRL_0
 #define P_MIRROR_CTRL                  REG_PORT_CTRL_1
 #define P_802_1P_CTRL                  REG_PORT_CTRL_2
-#define P_STP_CTRL                     REG_PORT_CTRL_2
 #define P_PASS_ALL_CTRL                        REG_PORT_CTRL_12
 #define P_INS_SRC_PVID_CTRL            REG_PORT_CTRL_12
 #define P_DROP_TAG_CTRL                        REG_PORT_CTRL_13
index fa498ad8ca4092eb5e70e971538f332cee240df1..0e808d27124ca957d3a271249c4f6c4b15b4c521 100644 (file)
@@ -338,6 +338,7 @@ void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member)
 
 void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port)
 {
+       const u16 *regs = dev->info->regs;
        u8 data;
 
        regmap_update_bits(dev->regmap[0], REG_SW_LUE_CTRL_2,
@@ -346,12 +347,12 @@ void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port)
 
        if (port < dev->info->port_cnt) {
                /* flush individual port */
-               ksz_pread8(dev, port, P_STP_CTRL, &data);
+               ksz_pread8(dev, port, regs[P_STP_CTRL], &data);
                if (!(data & PORT_LEARN_DISABLE))
-                       ksz_pwrite8(dev, port, P_STP_CTRL,
+                       ksz_pwrite8(dev, port, regs[P_STP_CTRL],
                                    data | PORT_LEARN_DISABLE);
                ksz_cfg(dev, S_FLUSH_TABLE_CTRL, SW_FLUSH_DYN_MAC_TABLE, true);
-               ksz_pwrite8(dev, port, P_STP_CTRL, data);
+               ksz_pwrite8(dev, port, regs[P_STP_CTRL], data);
        } else {
                /* flush all */
                ksz_cfg(dev, S_FLUSH_TABLE_CTRL, SW_FLUSH_STP_TABLE, true);
index 6be2efe6334ad8e43c917b77cecf1633dc0b2852..2ba0f4449130315dc96d43f3bbfe0c3eff9f9734 100644 (file)
 #define P_BCAST_STORM_CTRL             REG_PORT_MAC_CTRL_0
 #define P_PRIO_CTRL                    REG_PORT_MRI_PRIO_CTRL
 #define P_MIRROR_CTRL                  REG_PORT_MRI_MIRROR_CTRL
-#define P_STP_CTRL                     REG_PORT_LUE_MSTP_STATE
 #define P_PHY_CTRL                     REG_PORT_PHY_CTRL
 #define P_RATE_LIMIT_CTRL              REG_PORT_MAC_IN_RATE_LIMIT
 
index 4992fea208b14214e530f84d010296dc1d3339b7..2f336b991d5aafdd9068e310202ec5ce69359248 100644 (file)
@@ -216,6 +216,7 @@ static const u16 ksz8795_regs[] = {
        [P_REMOTE_STATUS]               = 0x08,
        [P_SPEED_STATUS]                = 0x09,
        [S_TAIL_TAG_CTRL]               = 0x0C,
+       [P_STP_CTRL]                    = 0x02,
 };
 
 static const u32 ksz8795_masks[] = {
@@ -266,6 +267,7 @@ static const u16 ksz8863_regs[] = {
        [P_REMOTE_STATUS]               = 0x0E,
        [P_SPEED_STATUS]                = 0x0F,
        [S_TAIL_TAG_CTRL]               = 0x03,
+       [P_STP_CTRL]                    = 0x02,
 };
 
 static const u32 ksz8863_masks[] = {
@@ -301,6 +303,11 @@ static u8 ksz8863_shifts[] = {
        [DYNAMIC_MAC_SRC_PORT]          = 20,
 };
 
+static const u16 ksz9477_regs[] = {
+       [P_STP_CTRL]                    = 0x0B04,
+
+};
+
 const struct ksz_chip_data ksz_switch_chips[] = {
        [KSZ8795] = {
                .chip_id = KSZ8795_CHIP_ID,
@@ -318,7 +325,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .regs = ksz8795_regs,
                .masks = ksz8795_masks,
                .shifts = ksz8795_shifts,
-               .stp_ctrl_reg = 0x02,
                .broadcast_ctrl_reg =  0x06,
                .multicast_ctrl_reg = 0x04,
                .start_ctrl_reg = 0x01,
@@ -358,7 +364,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .regs = ksz8795_regs,
                .masks = ksz8795_masks,
                .shifts = ksz8795_shifts,
-               .stp_ctrl_reg = 0x02,
                .broadcast_ctrl_reg =  0x06,
                .multicast_ctrl_reg = 0x04,
                .start_ctrl_reg = 0x01,
@@ -384,7 +389,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .regs = ksz8795_regs,
                .masks = ksz8795_masks,
                .shifts = ksz8795_shifts,
-               .stp_ctrl_reg = 0x02,
                .broadcast_ctrl_reg =  0x06,
                .multicast_ctrl_reg = 0x04,
                .start_ctrl_reg = 0x01,
@@ -409,7 +413,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .regs = ksz8863_regs,
                .masks = ksz8863_masks,
                .shifts = ksz8863_shifts,
-               .stp_ctrl_reg = 0x02,
                .broadcast_ctrl_reg =  0x06,
                .multicast_ctrl_reg = 0x04,
                .start_ctrl_reg = 0x01,
@@ -431,7 +434,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_names = ksz9477_mib_names,
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
-               .stp_ctrl_reg = 0x0B04,
+               .regs = ksz9477_regs,
                .broadcast_ctrl_reg =  0x0332,
                .multicast_ctrl_reg = 0x0331,
                .start_ctrl_reg = 0x0300,
@@ -458,7 +461,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_names = ksz9477_mib_names,
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
-               .stp_ctrl_reg = 0x0B04,
+               .regs = ksz9477_regs,
                .broadcast_ctrl_reg =  0x0332,
                .multicast_ctrl_reg = 0x0331,
                .start_ctrl_reg = 0x0300,
@@ -484,7 +487,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_names = ksz9477_mib_names,
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
-               .stp_ctrl_reg = 0x0B04,
+               .regs = ksz9477_regs,
                .broadcast_ctrl_reg =  0x0332,
                .multicast_ctrl_reg = 0x0331,
                .start_ctrl_reg = 0x0300,
@@ -507,7 +510,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_names = ksz9477_mib_names,
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
-               .stp_ctrl_reg = 0x0B04,
+               .regs = ksz9477_regs,
                .broadcast_ctrl_reg =  0x0332,
                .multicast_ctrl_reg = 0x0331,
                .start_ctrl_reg = 0x0300,
@@ -532,7 +535,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_names = ksz9477_mib_names,
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
-               .stp_ctrl_reg = 0x0B04,
+               .regs = ksz9477_regs,
                .broadcast_ctrl_reg =  0x0332,
                .multicast_ctrl_reg = 0x0331,
                .start_ctrl_reg = 0x0300,
@@ -553,7 +556,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_names = ksz9477_mib_names,
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
-               .stp_ctrl_reg = 0x0B04,
+               .regs = ksz9477_regs,
                .broadcast_ctrl_reg =  0x0332,
                .multicast_ctrl_reg = 0x0331,
                .start_ctrl_reg = 0x0300,
@@ -574,7 +577,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_names = ksz9477_mib_names,
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
-               .stp_ctrl_reg = 0x0B04,
+               .regs = ksz9477_regs,
                .broadcast_ctrl_reg =  0x0332,
                .multicast_ctrl_reg = 0x0331,
                .start_ctrl_reg = 0x0300,
@@ -599,7 +602,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_names = ksz9477_mib_names,
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
-               .stp_ctrl_reg = 0x0B04,
+               .regs = ksz9477_regs,
                .broadcast_ctrl_reg =  0x0332,
                .multicast_ctrl_reg = 0x0331,
                .start_ctrl_reg = 0x0300,
@@ -624,7 +627,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_names = ksz9477_mib_names,
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
-               .stp_ctrl_reg = 0x0B04,
+               .regs = ksz9477_regs,
                .broadcast_ctrl_reg =  0x0332,
                .multicast_ctrl_reg = 0x0331,
                .start_ctrl_reg = 0x0300,
@@ -1131,12 +1134,12 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
 {
        struct ksz_device *dev = ds->priv;
        struct ksz_port *p;
+       const u16 *regs;
        u8 data;
-       int reg;
 
-       reg = dev->info->stp_ctrl_reg;
+       regs = dev->info->regs;
 
-       ksz_pread8(dev, port, reg, &data);
+       ksz_pread8(dev, port, regs[P_STP_CTRL], &data);
        data &= ~(PORT_TX_ENABLE | PORT_RX_ENABLE | PORT_LEARN_DISABLE);
 
        switch (state) {
@@ -1160,7 +1163,7 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
                return;
        }
 
-       ksz_pwrite8(dev, port, reg, data);
+       ksz_pwrite8(dev, port, regs[P_STP_CTRL], data);
 
        p = &dev->ports[port];
        p->stp_state = state;
index 18794f571687af07c46a9617a24e247cec4aa94e..2a9b2b59fa79ec37ab6136dee84fa405f7317645 100644 (file)
@@ -164,6 +164,7 @@ enum ksz_regs {
        P_REMOTE_STATUS,
        P_SPEED_STATUS,
        S_TAIL_TAG_CTRL,
+       P_STP_CTRL,
 };
 
 enum ksz_masks {