net: dsa: microchip: add P_STP_CTRL to ksz_chip_reg
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>
This commit is contained in:
parent
a02579df16
commit
6877102f95
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -766,7 +766,6 @@
|
||||
#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
|
||||
|
@ -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);
|
||||
|
@ -1620,7 +1620,6 @@
|
||||
#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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -164,6 +164,7 @@ enum ksz_regs {
|
||||
P_REMOTE_STATUS,
|
||||
P_SPEED_STATUS,
|
||||
S_TAIL_TAG_CTRL,
|
||||
P_STP_CTRL,
|
||||
};
|
||||
|
||||
enum ksz_masks {
|
||||
|
Loading…
Reference in New Issue
Block a user