@@ -1038,6 +1038,7 @@ static int
10381038mt7530_port_enable (struct dsa_switch * ds , int port ,
10391039 struct phy_device * phy )
10401040{
1041+ struct dsa_port * dp = dsa_to_port (ds , port );
10411042 struct mt7530_priv * priv = ds -> priv ;
10421043
10431044 mutex_lock (& priv -> reg_mutex );
@@ -1046,7 +1047,11 @@ mt7530_port_enable(struct dsa_switch *ds, int port,
10461047 * restore the port matrix if the port is the member of a certain
10471048 * bridge.
10481049 */
1049- priv -> ports [port ].pm |= PCR_MATRIX (BIT (MT7530_CPU_PORT ));
1050+ if (dsa_port_is_user (dp )) {
1051+ struct dsa_port * cpu_dp = dp -> cpu_dp ;
1052+
1053+ priv -> ports [port ].pm |= PCR_MATRIX (BIT (cpu_dp -> index ));
1054+ }
10501055 priv -> ports [port ].enable = true;
10511056 mt7530_rmw (priv , MT7530_PCR_P (port ), PCR_MATRIX_MASK ,
10521057 priv -> ports [port ].pm );
@@ -1195,7 +1200,8 @@ mt7530_port_bridge_join(struct dsa_switch *ds, int port,
11951200 struct netlink_ext_ack * extack )
11961201{
11971202 struct dsa_port * dp = dsa_to_port (ds , port ), * other_dp ;
1198- u32 port_bitmap = BIT (MT7530_CPU_PORT );
1203+ struct dsa_port * cpu_dp = dp -> cpu_dp ;
1204+ u32 port_bitmap = BIT (cpu_dp -> index );
11991205 struct mt7530_priv * priv = ds -> priv ;
12001206
12011207 mutex_lock (& priv -> reg_mutex );
@@ -1272,9 +1278,12 @@ mt7530_port_set_vlan_unaware(struct dsa_switch *ds, int port)
12721278 * the CPU port get out of VLAN filtering mode.
12731279 */
12741280 if (all_user_ports_removed ) {
1275- mt7530_write (priv , MT7530_PCR_P (MT7530_CPU_PORT ),
1281+ struct dsa_port * dp = dsa_to_port (ds , port );
1282+ struct dsa_port * cpu_dp = dp -> cpu_dp ;
1283+
1284+ mt7530_write (priv , MT7530_PCR_P (cpu_dp -> index ),
12761285 PCR_MATRIX (dsa_user_ports (priv -> ds )));
1277- mt7530_write (priv , MT7530_PVC_P (MT7530_CPU_PORT ), PORT_SPEC_TAG
1286+ mt7530_write (priv , MT7530_PVC_P (cpu_dp -> index ), PORT_SPEC_TAG
12781287 | PVC_EG_TAG (MT7530_VLAN_EG_CONSISTENT ));
12791288 }
12801289}
@@ -1312,6 +1321,7 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
13121321 struct dsa_bridge bridge )
13131322{
13141323 struct dsa_port * dp = dsa_to_port (ds , port ), * other_dp ;
1324+ struct dsa_port * cpu_dp = dp -> cpu_dp ;
13151325 struct mt7530_priv * priv = ds -> priv ;
13161326
13171327 mutex_lock (& priv -> reg_mutex );
@@ -1340,8 +1350,8 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
13401350 */
13411351 if (priv -> ports [port ].enable )
13421352 mt7530_rmw (priv , MT7530_PCR_P (port ), PCR_MATRIX_MASK ,
1343- PCR_MATRIX (BIT (MT7530_CPU_PORT )));
1344- priv -> ports [port ].pm = PCR_MATRIX (BIT (MT7530_CPU_PORT ));
1353+ PCR_MATRIX (BIT (cpu_dp -> index )));
1354+ priv -> ports [port ].pm = PCR_MATRIX (BIT (cpu_dp -> index ));
13451355
13461356 /* When a port is removed from the bridge, the port would be set up
13471357 * back to the default as is at initial boot which is a VLAN-unaware
@@ -1508,14 +1518,17 @@ static int
15081518mt7530_port_vlan_filtering (struct dsa_switch * ds , int port , bool vlan_filtering ,
15091519 struct netlink_ext_ack * extack )
15101520{
1521+ struct dsa_port * dp = dsa_to_port (ds , port );
1522+ struct dsa_port * cpu_dp = dp -> cpu_dp ;
1523+
15111524 if (vlan_filtering ) {
15121525 /* The port is being kept as VLAN-unaware port when bridge is
15131526 * set up with vlan_filtering not being set, Otherwise, the
15141527 * port and the corresponding CPU port is required the setup
15151528 * for becoming a VLAN-aware port.
15161529 */
15171530 mt7530_port_set_vlan_aware (ds , port );
1518- mt7530_port_set_vlan_aware (ds , MT7530_CPU_PORT );
1531+ mt7530_port_set_vlan_aware (ds , cpu_dp -> index );
15191532 } else {
15201533 mt7530_port_set_vlan_unaware (ds , port );
15211534 }
0 commit comments