|
|
@ -629,25 +629,14 @@ static int rtl8366rb_get_vlan_port_pvid(struct rtl8366_smi *smi, int port, |
|
|
|
static int rtl8366rb_set_port_vlan_index(struct rtl8366_smi *smi, int port, |
|
|
|
static int rtl8366rb_set_port_vlan_index(struct rtl8366_smi *smi, int port, |
|
|
|
int index) |
|
|
|
int index) |
|
|
|
{ |
|
|
|
{ |
|
|
|
u32 data; |
|
|
|
|
|
|
|
int err; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (port >= RTL8366_NUM_PORTS || index >= RTL8366_NUM_VLANS) |
|
|
|
if (port >= RTL8366_NUM_PORTS || index >= RTL8366_NUM_VLANS) |
|
|
|
return -EINVAL; |
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
|
|
err = rtl8366_smi_read_reg(smi, RTL8366S_PORT_VLAN_CTRL_REG(port), |
|
|
|
return rtl8366_smi_rmwr(smi, RTL8366S_PORT_VLAN_CTRL_REG(port), |
|
|
|
&data); |
|
|
|
RTL8366S_PORT_VLAN_CTRL_MASK << |
|
|
|
if (err) |
|
|
|
RTL8366S_PORT_VLAN_CTRL_SHIFT(port), |
|
|
|
return err; |
|
|
|
(index & RTL8366S_PORT_VLAN_CTRL_MASK) << |
|
|
|
|
|
|
|
RTL8366S_PORT_VLAN_CTRL_SHIFT(port)); |
|
|
|
data &= ~(RTL8366S_PORT_VLAN_CTRL_MASK << |
|
|
|
|
|
|
|
RTL8366S_PORT_VLAN_CTRL_SHIFT(port)); |
|
|
|
|
|
|
|
data |= (index & RTL8366S_PORT_VLAN_CTRL_MASK) << |
|
|
|
|
|
|
|
RTL8366S_PORT_VLAN_CTRL_SHIFT(port); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err = rtl8366_smi_write_reg(smi, RTL8366S_PORT_VLAN_CTRL_REG(port), |
|
|
|
|
|
|
|
data); |
|
|
|
|
|
|
|
return err; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int rtl8366rb_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, |
|
|
|
static int rtl8366rb_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, |
|
|
@ -721,30 +710,16 @@ static int rtl8366rb_set_vlan_port_pvid(struct rtl8366_smi *smi, int port, |
|
|
|
|
|
|
|
|
|
|
|
static int rtl8366rb_vlan_set_vlan(struct rtl8366_smi *smi, int enable) |
|
|
|
static int rtl8366rb_vlan_set_vlan(struct rtl8366_smi *smi, int enable) |
|
|
|
{ |
|
|
|
{ |
|
|
|
u32 data = 0; |
|
|
|
return rtl8366_smi_rmwr(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, |
|
|
|
|
|
|
|
RTL8366_CHIP_CTRL_VLAN, |
|
|
|
rtl8366_smi_read_reg(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, &data); |
|
|
|
(enable) ? RTL8366_CHIP_CTRL_VLAN : 0); |
|
|
|
|
|
|
|
|
|
|
|
if (enable) |
|
|
|
|
|
|
|
data |= RTL8366_CHIP_CTRL_VLAN; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
data &= ~RTL8366_CHIP_CTRL_VLAN; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rtl8366_smi_write_reg(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int rtl8366rb_vlan_set_4ktable(struct rtl8366_smi *smi, int enable) |
|
|
|
static int rtl8366rb_vlan_set_4ktable(struct rtl8366_smi *smi, int enable) |
|
|
|
{ |
|
|
|
{ |
|
|
|
u32 data = 0; |
|
|
|
return rtl8366_smi_rmwr(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, |
|
|
|
|
|
|
|
RTL8366_CHIP_CTRL_VLAN_4KTB, |
|
|
|
rtl8366_smi_read_reg(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, &data); |
|
|
|
(enable) ? RTL8366_CHIP_CTRL_VLAN_4KTB : 0); |
|
|
|
|
|
|
|
|
|
|
|
if (enable) |
|
|
|
|
|
|
|
data |= RTL8366_CHIP_CTRL_VLAN_4KTB; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
data &= ~RTL8366_CHIP_CTRL_VLAN_4KTB; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rtl8366_smi_write_reg(smi, RTL8366_CHIP_GLOBAL_CTRL_REG, data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int rtl8366rb_reset_vlan(struct rtl8366_smi *smi) |
|
|
|
static int rtl8366rb_reset_vlan(struct rtl8366_smi *smi) |
|
|
@ -1013,15 +988,12 @@ static int rtl8366rb_sw_reset_mibs(struct switch_dev *dev, |
|
|
|
struct switch_val *val) |
|
|
|
struct switch_val *val) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); |
|
|
|
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); |
|
|
|
u32 data = 0; |
|
|
|
int err = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (val->value.i == 1) { |
|
|
|
if (val->value.i == 1) |
|
|
|
rtl8366_smi_read_reg(smi, RTL8366S_MIB_CTRL_REG, &data); |
|
|
|
err = rtl8366_smi_rmwr(smi, RTL8366S_MIB_CTRL_REG, 0, (1 << 2)); |
|
|
|
data |= (1 << 2); |
|
|
|
|
|
|
|
rtl8366_smi_write_reg(smi, RTL8366S_MIB_CTRL_REG, data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return err; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int rtl8366rb_sw_get_vlan_enable(struct switch_dev *dev, |
|
|
|
static int rtl8366rb_sw_get_vlan_enable(struct switch_dev *dev, |
|
|
@ -1069,19 +1041,13 @@ static int rtl8366rb_sw_set_blinkrate(struct switch_dev *dev, |
|
|
|
struct switch_val *val) |
|
|
|
struct switch_val *val) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); |
|
|
|
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); |
|
|
|
u32 data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (val->value.i >= 6) |
|
|
|
if (val->value.i >= 6) |
|
|
|
return -EINVAL; |
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
|
|
rtl8366_smi_read_reg(smi, RTL8366_LED_BLINKRATE_REG, &data); |
|
|
|
return rtl8366_smi_rmwr(smi, RTL8366_LED_BLINKRATE_REG, |
|
|
|
|
|
|
|
RTL8366_LED_BLINKRATE_MASK, |
|
|
|
data &= ~RTL8366_LED_BLINKRATE_MASK; |
|
|
|
val->value.i); |
|
|
|
data |= val->value.i; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rtl8366_smi_write_reg(smi, RTL8366_LED_BLINKRATE_REG, data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int rtl8366rb_sw_set_vlan_enable(struct switch_dev *dev, |
|
|
|
static int rtl8366rb_sw_set_vlan_enable(struct switch_dev *dev, |
|
|
@ -1208,23 +1174,24 @@ static int rtl8366rb_sw_set_port_led(struct switch_dev *dev, |
|
|
|
struct switch_val *val) |
|
|
|
struct switch_val *val) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); |
|
|
|
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); |
|
|
|
u32 data = 0; |
|
|
|
u32 data; |
|
|
|
|
|
|
|
u32 mask; |
|
|
|
|
|
|
|
u32 reg; |
|
|
|
|
|
|
|
|
|
|
|
if (val->port_vlan >= RTL8366_NUM_PORTS) |
|
|
|
if (val->port_vlan >= RTL8366_NUM_PORTS) |
|
|
|
return -EINVAL; |
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
|
|
if (val->port_vlan == RTL8366_PORT_NUM_CPU) { |
|
|
|
if (val->port_vlan == RTL8366_PORT_NUM_CPU) { |
|
|
|
rtl8366_smi_read_reg(smi, RTL8366_LED_BLINKRATE_REG, &data); |
|
|
|
reg = RTL8366_LED_BLINKRATE_REG; |
|
|
|
data = (data & (~(0xF << 4))) | (val->value.i << 4); |
|
|
|
mask = 0xF << 4; |
|
|
|
rtl8366_smi_write_reg(smi, RTL8366_LED_BLINKRATE_REG, data); |
|
|
|
data = val->value.i << 4; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
rtl8366_smi_read_reg(smi, RTL8366_LED_CTRL_REG, &data); |
|
|
|
reg = RTL8366_LED_CTRL_REG; |
|
|
|
data = (data & (~(0xF << (val->port_vlan * 4)))) | |
|
|
|
mask = 0xF << (val->port_vlan * 4), |
|
|
|
(val->value.i << (val->port_vlan * 4)); |
|
|
|
data = val->value.i << (val->port_vlan * 4); |
|
|
|
rtl8366_smi_write_reg(smi, RTL8366_LED_CTRL_REG, data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return rtl8366_smi_rmwr(smi, RTL8366_LED_BLINKRATE_REG, mask, data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int rtl8366rb_sw_get_port_led(struct switch_dev *dev, |
|
|
|
static int rtl8366rb_sw_get_port_led(struct switch_dev *dev, |
|
|
@ -1248,16 +1215,12 @@ static int rtl8366rb_sw_reset_port_mibs(struct switch_dev *dev, |
|
|
|
struct switch_val *val) |
|
|
|
struct switch_val *val) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); |
|
|
|
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); |
|
|
|
u32 data = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (val->port_vlan >= RTL8366_NUM_PORTS) |
|
|
|
if (val->port_vlan >= RTL8366_NUM_PORTS) |
|
|
|
return -EINVAL; |
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
|
|
rtl8366_smi_read_reg(smi, RTL8366S_MIB_CTRL_REG, &data); |
|
|
|
return rtl8366_smi_rmwr(smi, RTL8366S_MIB_CTRL_REG, |
|
|
|
data |= (1 << (val->port_vlan + 3)); |
|
|
|
0, (1 << (val->port_vlan + 3))); |
|
|
|
rtl8366_smi_write_reg(smi, RTL8366S_MIB_CTRL_REG, data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int rtl8366rb_sw_get_port_mib(struct switch_dev *dev, |
|
|
|
static int rtl8366rb_sw_get_port_mib(struct switch_dev *dev, |
|
|
|