.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2017 Pengutronix, Juergen Borleis <kernel@pengutronix.de> |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or |
---|
5 | | - * modify it under the terms of the GNU General Public License |
---|
6 | | - * version 2, as published by the Free Software Foundation. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | | - * |
---|
13 | 4 | */ |
---|
14 | 5 | #include <linux/kernel.h> |
---|
15 | 6 | #include <linux/module.h> |
---|
.. | .. |
---|
898 | 889 | /* ---------------------------- DSA -----------------------------------*/ |
---|
899 | 890 | |
---|
900 | 891 | static enum dsa_tag_protocol lan9303_get_tag_protocol(struct dsa_switch *ds, |
---|
901 | | - int port) |
---|
| 892 | + int port, |
---|
| 893 | + enum dsa_tag_protocol mp) |
---|
902 | 894 | { |
---|
903 | 895 | return DSA_TAG_PROTO_LAN9303; |
---|
904 | 896 | } |
---|
.. | .. |
---|
966 | 958 | { .offset = LAN9303_MAC_TX_BRDCST_CNT_0, .name = "TxBroad", }, |
---|
967 | 959 | { .offset = LAN9303_MAC_TX_PAUSE_CNT_0, .name = "TxPause", }, |
---|
968 | 960 | { .offset = LAN9303_MAC_TX_MULCST_CNT_0, .name = "TxMulti", }, |
---|
969 | | - { .offset = LAN9303_MAC_RX_UNDSZE_CNT_0, .name = "TxUnderRun", }, |
---|
| 961 | + { .offset = LAN9303_MAC_RX_UNDSZE_CNT_0, .name = "RxShort", }, |
---|
970 | 962 | { .offset = LAN9303_MAC_TX_64_CNT_0, .name = "Tx64Byte", }, |
---|
971 | 963 | { .offset = LAN9303_MAC_TX_127_CNT_0, .name = "Tx128Byte", }, |
---|
972 | 964 | { .offset = LAN9303_MAC_TX_255_CNT_0, .name = "Tx256Byte", }, |
---|
.. | .. |
---|
1010 | 1002 | ret = lan9303_read_switch_port( |
---|
1011 | 1003 | chip, port, lan9303_mib[u].offset, ®); |
---|
1012 | 1004 | |
---|
1013 | | - if (ret) |
---|
| 1005 | + if (ret) { |
---|
1014 | 1006 | dev_warn(chip->dev, "Reading status port %d reg %u failed\n", |
---|
1015 | 1007 | port, lan9303_mib[u].offset); |
---|
| 1008 | + reg = 0; |
---|
| 1009 | + } |
---|
1016 | 1010 | data[u] = reg; |
---|
1017 | 1011 | } |
---|
1018 | 1012 | } |
---|
.. | .. |
---|
1056 | 1050 | struct phy_device *phydev) |
---|
1057 | 1051 | { |
---|
1058 | 1052 | struct lan9303 *chip = ds->priv; |
---|
1059 | | - int ctl, res; |
---|
| 1053 | + int ctl; |
---|
1060 | 1054 | |
---|
1061 | 1055 | if (!phy_is_pseudo_fixed_link(phydev)) |
---|
1062 | 1056 | return; |
---|
.. | .. |
---|
1077 | 1071 | else |
---|
1078 | 1072 | ctl &= ~BMCR_FULLDPLX; |
---|
1079 | 1073 | |
---|
1080 | | - res = lan9303_phy_write(ds, port, MII_BMCR, ctl); |
---|
| 1074 | + lan9303_phy_write(ds, port, MII_BMCR, ctl); |
---|
1081 | 1075 | |
---|
1082 | 1076 | if (port == chip->phy_addr_base) { |
---|
1083 | 1077 | /* Virtual Phy: Remove Turbo 200Mbit mode */ |
---|
1084 | 1078 | lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl); |
---|
1085 | 1079 | |
---|
1086 | 1080 | ctl &= ~LAN9303_VIRT_SPECIAL_TURBO; |
---|
1087 | | - res = regmap_write(chip->regmap, |
---|
1088 | | - LAN9303_VIRT_SPECIAL_CTRL, ctl); |
---|
| 1081 | + regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl); |
---|
1089 | 1082 | } |
---|
1090 | 1083 | } |
---|
1091 | 1084 | |
---|
.. | .. |
---|
1094 | 1087 | { |
---|
1095 | 1088 | struct lan9303 *chip = ds->priv; |
---|
1096 | 1089 | |
---|
| 1090 | + if (!dsa_is_user_port(ds, port)) |
---|
| 1091 | + return 0; |
---|
| 1092 | + |
---|
1097 | 1093 | return lan9303_enable_processing_port(chip, port); |
---|
1098 | 1094 | } |
---|
1099 | 1095 | |
---|
1100 | | -static void lan9303_port_disable(struct dsa_switch *ds, int port, |
---|
1101 | | - struct phy_device *phy) |
---|
| 1096 | +static void lan9303_port_disable(struct dsa_switch *ds, int port) |
---|
1102 | 1097 | { |
---|
1103 | 1098 | struct lan9303 *chip = ds->priv; |
---|
| 1099 | + |
---|
| 1100 | + if (!dsa_is_user_port(ds, port)) |
---|
| 1101 | + return; |
---|
1104 | 1102 | |
---|
1105 | 1103 | lan9303_disable_processing_port(chip, port); |
---|
1106 | 1104 | lan9303_phy_write(ds, chip->phy_addr_base + port, MII_BMCR, BMCR_PDOWN); |
---|
.. | .. |
---|
1189 | 1187 | struct lan9303 *chip = ds->priv; |
---|
1190 | 1188 | |
---|
1191 | 1189 | dev_dbg(chip->dev, "%s(%d, %pM, %d)\n", __func__, port, addr, vid); |
---|
1192 | | - if (vid) |
---|
1193 | | - return -EOPNOTSUPP; |
---|
1194 | 1190 | |
---|
1195 | 1191 | return lan9303_alr_add_port(chip, addr, port, false); |
---|
1196 | 1192 | } |
---|
.. | .. |
---|
1202 | 1198 | struct lan9303 *chip = ds->priv; |
---|
1203 | 1199 | |
---|
1204 | 1200 | dev_dbg(chip->dev, "%s(%d, %pM, %d)\n", __func__, port, addr, vid); |
---|
1205 | | - if (vid) |
---|
1206 | | - return -EOPNOTSUPP; |
---|
1207 | 1201 | lan9303_alr_del_port(chip, addr, port); |
---|
1208 | 1202 | |
---|
1209 | 1203 | return 0; |
---|
.. | .. |
---|
1291 | 1285 | { |
---|
1292 | 1286 | int base; |
---|
1293 | 1287 | |
---|
1294 | | - chip->ds = dsa_switch_alloc(chip->dev, LAN9303_NUM_PORTS); |
---|
| 1288 | + chip->ds = devm_kzalloc(chip->dev, sizeof(*chip->ds), GFP_KERNEL); |
---|
1295 | 1289 | if (!chip->ds) |
---|
1296 | 1290 | return -ENOMEM; |
---|
1297 | 1291 | |
---|
| 1292 | + chip->ds->dev = chip->dev; |
---|
| 1293 | + chip->ds->num_ports = LAN9303_NUM_PORTS; |
---|
1298 | 1294 | chip->ds->priv = chip; |
---|
1299 | 1295 | chip->ds->ops = &lan9303_switch_ops; |
---|
1300 | 1296 | base = chip->phy_addr_base; |
---|