| .. | .. |
|---|
| 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", }, |
|---|
| .. | .. |
|---|
| 1056 | 1048 | struct phy_device *phydev) |
|---|
| 1057 | 1049 | { |
|---|
| 1058 | 1050 | struct lan9303 *chip = ds->priv; |
|---|
| 1059 | | - int ctl, res; |
|---|
| 1051 | + int ctl; |
|---|
| 1060 | 1052 | |
|---|
| 1061 | 1053 | if (!phy_is_pseudo_fixed_link(phydev)) |
|---|
| 1062 | 1054 | return; |
|---|
| .. | .. |
|---|
| 1077 | 1069 | else |
|---|
| 1078 | 1070 | ctl &= ~BMCR_FULLDPLX; |
|---|
| 1079 | 1071 | |
|---|
| 1080 | | - res = lan9303_phy_write(ds, port, MII_BMCR, ctl); |
|---|
| 1072 | + lan9303_phy_write(ds, port, MII_BMCR, ctl); |
|---|
| 1081 | 1073 | |
|---|
| 1082 | 1074 | if (port == chip->phy_addr_base) { |
|---|
| 1083 | 1075 | /* Virtual Phy: Remove Turbo 200Mbit mode */ |
|---|
| 1084 | 1076 | lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl); |
|---|
| 1085 | 1077 | |
|---|
| 1086 | 1078 | ctl &= ~LAN9303_VIRT_SPECIAL_TURBO; |
|---|
| 1087 | | - res = regmap_write(chip->regmap, |
|---|
| 1088 | | - LAN9303_VIRT_SPECIAL_CTRL, ctl); |
|---|
| 1079 | + regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl); |
|---|
| 1089 | 1080 | } |
|---|
| 1090 | 1081 | } |
|---|
| 1091 | 1082 | |
|---|
| .. | .. |
|---|
| 1094 | 1085 | { |
|---|
| 1095 | 1086 | struct lan9303 *chip = ds->priv; |
|---|
| 1096 | 1087 | |
|---|
| 1088 | + if (!dsa_is_user_port(ds, port)) |
|---|
| 1089 | + return 0; |
|---|
| 1090 | + |
|---|
| 1097 | 1091 | return lan9303_enable_processing_port(chip, port); |
|---|
| 1098 | 1092 | } |
|---|
| 1099 | 1093 | |
|---|
| 1100 | | -static void lan9303_port_disable(struct dsa_switch *ds, int port, |
|---|
| 1101 | | - struct phy_device *phy) |
|---|
| 1094 | +static void lan9303_port_disable(struct dsa_switch *ds, int port) |
|---|
| 1102 | 1095 | { |
|---|
| 1103 | 1096 | struct lan9303 *chip = ds->priv; |
|---|
| 1097 | + |
|---|
| 1098 | + if (!dsa_is_user_port(ds, port)) |
|---|
| 1099 | + return; |
|---|
| 1104 | 1100 | |
|---|
| 1105 | 1101 | lan9303_disable_processing_port(chip, port); |
|---|
| 1106 | 1102 | lan9303_phy_write(ds, chip->phy_addr_base + port, MII_BMCR, BMCR_PDOWN); |
|---|
| .. | .. |
|---|
| 1291 | 1287 | { |
|---|
| 1292 | 1288 | int base; |
|---|
| 1293 | 1289 | |
|---|
| 1294 | | - chip->ds = dsa_switch_alloc(chip->dev, LAN9303_NUM_PORTS); |
|---|
| 1290 | + chip->ds = devm_kzalloc(chip->dev, sizeof(*chip->ds), GFP_KERNEL); |
|---|
| 1295 | 1291 | if (!chip->ds) |
|---|
| 1296 | 1292 | return -ENOMEM; |
|---|
| 1297 | 1293 | |
|---|
| 1294 | + chip->ds->dev = chip->dev; |
|---|
| 1295 | + chip->ds->num_ports = LAN9303_NUM_PORTS; |
|---|
| 1298 | 1296 | chip->ds->priv = chip; |
|---|
| 1299 | 1297 | chip->ds->ops = &lan9303_switch_ops; |
|---|
| 1300 | 1298 | base = chip->phy_addr_base; |
|---|