+ for (i = 0; i < RT305X_ESW_NUM_VLANS; i++) {
+ rt305x_esw_set_vlan_id(esw, i, 0);
+ rt305x_esw_set_vmsc(esw, i, 0);
+ }
+
+ for (i = 0; i < RT305X_ESW_NUM_PORTS; i++)
+ rt305x_esw_set_pvid(esw, i, 1);
+
+ switch (esw->pdata->vlan_config) {
+ case RT305X_ESW_VLAN_CONFIG_NONE:
+ break;
+
+ case RT305X_ESW_VLAN_CONFIG_BYPASS:
+ /* Pass all vlan tags to all ports */
+ for (i = 0; i < RT305X_ESW_NUM_VLANS; i++) {
+ rt305x_esw_set_vlan_id(esw, i, i+1);
+ rt305x_esw_set_vmsc(esw, i, RT305X_ESW_PORTS_ALL);
+ }
+ /* Disable VLAN TAG removal, keep aging on. */
+ rt305x_esw_wr(esw,
+ RT305X_ESW_PORTS_ALL << RT305X_ESW_POC3_ENAGING_S,
+ RT305X_ESW_REG_POC3);
+ break;
+
+ case RT305X_ESW_VLAN_CONFIG_LLLLW:
+ rt305x_esw_set_vlan_id(esw, 0, 1);
+ rt305x_esw_set_vlan_id(esw, 1, 2);
+ rt305x_esw_set_pvid(esw, RT305X_ESW_PORT4, 2);
+
+ rt305x_esw_set_vmsc(esw, 0,
+ BIT(RT305X_ESW_PORT0) | BIT(RT305X_ESW_PORT1) |
+ BIT(RT305X_ESW_PORT2) | BIT(RT305X_ESW_PORT3) |
+ BIT(RT305X_ESW_PORT6));
+ rt305x_esw_set_vmsc(esw, 1,
+ BIT(RT305X_ESW_PORT4) | BIT(RT305X_ESW_PORT6));
+ break;
+
+ case RT305X_ESW_VLAN_CONFIG_WLLLL:
+ rt305x_esw_set_vlan_id(esw, 0, 1);
+ rt305x_esw_set_vlan_id(esw, 1, 2);
+ rt305x_esw_set_pvid(esw, RT305X_ESW_PORT0, 2);
+
+ rt305x_esw_set_vmsc(esw, 0,
+ BIT(RT305X_ESW_PORT1) | BIT(RT305X_ESW_PORT2) |
+ BIT(RT305X_ESW_PORT3) | BIT(RT305X_ESW_PORT4) |
+ BIT(RT305X_ESW_PORT6));
+ rt305x_esw_set_vmsc(esw, 1,
+ BIT(RT305X_ESW_PORT0) | BIT(RT305X_ESW_PORT6));
+ break;
+
+ default:
+ BUG();
+ }