diff options
author | WingMan Kwok | 2013-05-14 12:59:53 -0500 |
---|---|---|
committer | Murali Karicheri | 2014-12-03 10:29:49 -0600 |
commit | c3fc55b829ea05a42d38fe59f503ea76cf066e8c (patch) | |
tree | 39823e2bb43dc44d312b7aeb97edd6d24c4467a9 /drivers/net/ethernet/ti/keystone_ethss.c | |
parent | 30c007603b0f10c7dd62ef2d765c801bdadeae84 (diff) | |
download | linux-c3fc55b829ea05a42d38fe59f503ea76cf066e8c.tar.gz linux-c3fc55b829ea05a42d38fe59f503ea76cf066e8c.tar.xz linux-c3fc55b829ea05a42d38fe59f503ea76cf066e8c.zip |
net: keystone: add ethtool get and set settings
This patch adds support of ethtool set and get settings.
Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
Diffstat (limited to 'drivers/net/ethernet/ti/keystone_ethss.c')
-rw-r--r-- | drivers/net/ethernet/ti/keystone_ethss.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/drivers/net/ethernet/ti/keystone_ethss.c b/drivers/net/ethernet/ti/keystone_ethss.c index 8b22272bcec..27c6ce34982 100644 --- a/drivers/net/ethernet/ti/keystone_ethss.c +++ b/drivers/net/ethernet/ti/keystone_ethss.c | |||
@@ -83,6 +83,7 @@ struct cpsw_slave { | |||
83 | const char *phy_id; | 83 | const char *phy_id; |
84 | struct cpsw_ale *ale; | 84 | struct cpsw_ale *ale; |
85 | u32 link_interface; | 85 | u32 link_interface; |
86 | u8 phy_port_t; | ||
86 | }; | 87 | }; |
87 | 88 | ||
88 | struct cpsw_ss_regs { | 89 | struct cpsw_ss_regs { |
@@ -1218,6 +1219,63 @@ static void keystone_get_ethtool_stats(struct net_device *ndev, | |||
1218 | return; | 1219 | return; |
1219 | } | 1220 | } |
1220 | 1221 | ||
1222 | static int keystone_get_settings(struct net_device *ndev, | ||
1223 | struct ethtool_cmd *cmd) | ||
1224 | { | ||
1225 | struct phy_device *phy = ndev->phydev; | ||
1226 | struct cpsw_slave *slave; | ||
1227 | int ret; | ||
1228 | |||
1229 | if (!phy) | ||
1230 | return -EINVAL; | ||
1231 | |||
1232 | slave = (struct cpsw_slave *)phy->context; | ||
1233 | if (!slave) | ||
1234 | return -EINVAL; | ||
1235 | |||
1236 | ret = phy_ethtool_gset(phy, cmd); | ||
1237 | if (!ret) | ||
1238 | cmd->port = slave->phy_port_t; | ||
1239 | |||
1240 | return ret; | ||
1241 | } | ||
1242 | |||
1243 | static int keystone_set_settings(struct net_device *ndev, | ||
1244 | struct ethtool_cmd *cmd) | ||
1245 | { | ||
1246 | struct phy_device *phy = ndev->phydev; | ||
1247 | struct cpsw_slave *slave; | ||
1248 | u32 features = cmd->advertising & cmd->supported; | ||
1249 | |||
1250 | if (!phy) | ||
1251 | return -EINVAL; | ||
1252 | |||
1253 | slave = (struct cpsw_slave *)phy->context; | ||
1254 | if (!slave) | ||
1255 | return -EINVAL; | ||
1256 | |||
1257 | if (cmd->port != slave->phy_port_t) { | ||
1258 | if ((cmd->port == PORT_TP) && !(features & ADVERTISED_TP)) | ||
1259 | return -EINVAL; | ||
1260 | |||
1261 | if ((cmd->port == PORT_AUI) && !(features & ADVERTISED_AUI)) | ||
1262 | return -EINVAL; | ||
1263 | |||
1264 | if ((cmd->port == PORT_BNC) && !(features & ADVERTISED_BNC)) | ||
1265 | return -EINVAL; | ||
1266 | |||
1267 | if ((cmd->port == PORT_MII) && !(features & ADVERTISED_MII)) | ||
1268 | return -EINVAL; | ||
1269 | |||
1270 | if ((cmd->port == PORT_FIBRE) && !(features & ADVERTISED_FIBRE)) | ||
1271 | return -EINVAL; | ||
1272 | } | ||
1273 | |||
1274 | slave->phy_port_t = cmd->port; | ||
1275 | |||
1276 | return phy_ethtool_sset(phy, cmd); | ||
1277 | } | ||
1278 | |||
1221 | static const struct ethtool_ops keystone_ethtool_ops = { | 1279 | static const struct ethtool_ops keystone_ethtool_ops = { |
1222 | .get_drvinfo = keystone_get_drvinfo, | 1280 | .get_drvinfo = keystone_get_drvinfo, |
1223 | .get_link = ethtool_op_get_link, | 1281 | .get_link = ethtool_op_get_link, |
@@ -1226,6 +1284,8 @@ static const struct ethtool_ops keystone_ethtool_ops = { | |||
1226 | .get_strings = keystone_get_stat_strings, | 1284 | .get_strings = keystone_get_stat_strings, |
1227 | .get_sset_count = keystone_get_sset_count, | 1285 | .get_sset_count = keystone_get_sset_count, |
1228 | .get_ethtool_stats = keystone_get_ethtool_stats, | 1286 | .get_ethtool_stats = keystone_get_ethtool_stats, |
1287 | .get_settings = keystone_get_settings, | ||
1288 | .set_settings = keystone_set_settings, | ||
1229 | }; | 1289 | }; |
1230 | 1290 | ||
1231 | #define mac_hi(mac) (((mac)[0] << 0) | ((mac)[1] << 8) | \ | 1291 | #define mac_hi(mac) (((mac)[0] << 0) | ((mac)[1] << 8) | \ |
@@ -1415,6 +1475,7 @@ static void cpsw_slave_open(struct cpsw_slave *slave, | |||
1415 | dev_info(priv->dev, "phy found: id is: 0x%s\n", | 1475 | dev_info(priv->dev, "phy found: id is: 0x%s\n", |
1416 | dev_name(&slave->phy->dev)); | 1476 | dev_name(&slave->phy->dev)); |
1417 | cpsw_intf->ndev->phydev = slave->phy; | 1477 | cpsw_intf->ndev->phydev = slave->phy; |
1478 | slave->phy_port_t = PORT_MII; | ||
1418 | phy_start(slave->phy); | 1479 | phy_start(slave->phy); |
1419 | } | 1480 | } |
1420 | } | 1481 | } |