.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2015 Cavium, Inc. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify it |
---|
5 | | - * under the terms of version 2 of the GNU General Public License |
---|
6 | | - * as published by the Free Software Foundation. |
---|
7 | 4 | */ |
---|
8 | 5 | |
---|
9 | 6 | #include <linux/acpi.h> |
---|
.. | .. |
---|
971 | 968 | lmac->last_duplex = (an_result >> 1) & 0x1; |
---|
972 | 969 | switch (speed) { |
---|
973 | 970 | case 0: |
---|
974 | | - lmac->last_speed = 10; |
---|
| 971 | + lmac->last_speed = SPEED_10; |
---|
975 | 972 | break; |
---|
976 | 973 | case 1: |
---|
977 | | - lmac->last_speed = 100; |
---|
| 974 | + lmac->last_speed = SPEED_100; |
---|
978 | 975 | break; |
---|
979 | 976 | case 2: |
---|
980 | | - lmac->last_speed = 1000; |
---|
| 977 | + lmac->last_speed = SPEED_1000; |
---|
981 | 978 | break; |
---|
982 | 979 | default: |
---|
983 | 980 | lmac->link_up = false; |
---|
.. | .. |
---|
1019 | 1016 | |
---|
1020 | 1017 | if ((spu_link & SPU_STATUS1_RCV_LNK) && |
---|
1021 | 1018 | !(smu_link & SMU_RX_CTL_STATUS)) { |
---|
1022 | | - lmac->link_up = 1; |
---|
| 1019 | + lmac->link_up = true; |
---|
1023 | 1020 | if (lmac->lmac_type == BGX_MODE_XLAUI) |
---|
1024 | | - lmac->last_speed = 40000; |
---|
| 1021 | + lmac->last_speed = SPEED_40000; |
---|
1025 | 1022 | else |
---|
1026 | | - lmac->last_speed = 10000; |
---|
1027 | | - lmac->last_duplex = 1; |
---|
| 1023 | + lmac->last_speed = SPEED_10000; |
---|
| 1024 | + lmac->last_duplex = DUPLEX_FULL; |
---|
1028 | 1025 | } else { |
---|
1029 | | - lmac->link_up = 0; |
---|
| 1026 | + lmac->link_up = false; |
---|
1030 | 1027 | lmac->last_speed = SPEED_UNKNOWN; |
---|
1031 | 1028 | lmac->last_duplex = DUPLEX_UNKNOWN; |
---|
1032 | 1029 | } |
---|
.. | .. |
---|
1035 | 1032 | if (lmac->link_up) { |
---|
1036 | 1033 | if (bgx_xaui_check_link(lmac)) { |
---|
1037 | 1034 | /* Errors, clear link_up state */ |
---|
1038 | | - lmac->link_up = 0; |
---|
| 1035 | + lmac->link_up = false; |
---|
1039 | 1036 | lmac->last_speed = SPEED_UNKNOWN; |
---|
1040 | 1037 | lmac->last_duplex = DUPLEX_UNKNOWN; |
---|
1041 | 1038 | } |
---|
.. | .. |
---|
1051 | 1048 | if (lmac_type == BGX_MODE_QSGMII) |
---|
1052 | 1049 | return PHY_INTERFACE_MODE_QSGMII; |
---|
1053 | 1050 | if (lmac_type == BGX_MODE_RGMII) |
---|
1054 | | - return PHY_INTERFACE_MODE_RGMII; |
---|
| 1051 | + return PHY_INTERFACE_MODE_RGMII_RXID; |
---|
1055 | 1052 | |
---|
1056 | 1053 | return PHY_INTERFACE_MODE_SGMII; |
---|
1057 | 1054 | } |
---|
.. | .. |
---|
1067 | 1064 | if ((lmac->lmac_type == BGX_MODE_SGMII) || |
---|
1068 | 1065 | (lmac->lmac_type == BGX_MODE_QSGMII) || |
---|
1069 | 1066 | (lmac->lmac_type == BGX_MODE_RGMII)) { |
---|
1070 | | - lmac->is_sgmii = 1; |
---|
| 1067 | + lmac->is_sgmii = true; |
---|
1071 | 1068 | if (bgx_lmac_sgmii_init(bgx, lmac)) |
---|
1072 | 1069 | return -1; |
---|
1073 | 1070 | } else { |
---|
1074 | | - lmac->is_sgmii = 0; |
---|
| 1071 | + lmac->is_sgmii = false; |
---|
1075 | 1072 | if (bgx_lmac_xaui_init(bgx, lmac)) |
---|
1076 | 1073 | return -1; |
---|
1077 | 1074 | } |
---|
.. | .. |
---|
1114 | 1111 | } else { |
---|
1115 | 1112 | /* Default to below link speed and duplex */ |
---|
1116 | 1113 | lmac->link_up = true; |
---|
1117 | | - lmac->last_speed = 1000; |
---|
1118 | | - lmac->last_duplex = 1; |
---|
| 1114 | + lmac->last_speed = SPEED_1000; |
---|
| 1115 | + lmac->last_duplex = DUPLEX_FULL; |
---|
1119 | 1116 | bgx_sgmii_change_link_state(lmac); |
---|
1120 | 1117 | return 0; |
---|
1121 | 1118 | } |
---|
.. | .. |
---|
1226 | 1223 | |
---|
1227 | 1224 | /* Disable MAC steering (NCSI traffic) */ |
---|
1228 | 1225 | for (i = 0; i < RX_TRAFFIC_STEER_RULE_COUNT; i++) |
---|
1229 | | - bgx_reg_write(bgx, 0, BGX_CMR_RX_STREERING + (i * 8), 0x00); |
---|
| 1226 | + bgx_reg_write(bgx, 0, BGX_CMR_RX_STEERING + (i * 8), 0x00); |
---|
1230 | 1227 | } |
---|
1231 | 1228 | |
---|
1232 | 1229 | static u8 bgx_get_lane2sds_cfg(struct bgx *bgx, struct lmac *lmac) |
---|
.. | .. |
---|
1316 | 1313 | { |
---|
1317 | 1314 | if ((lmac->lmac_type != BGX_MODE_10G_KR) && |
---|
1318 | 1315 | (lmac->lmac_type != BGX_MODE_40G_KR)) { |
---|
1319 | | - lmac->use_training = 0; |
---|
| 1316 | + lmac->use_training = false; |
---|
1320 | 1317 | return; |
---|
1321 | 1318 | } |
---|
1322 | 1319 | |
---|
.. | .. |
---|
1393 | 1390 | u8 *dst) |
---|
1394 | 1391 | { |
---|
1395 | 1392 | u8 mac[ETH_ALEN]; |
---|
1396 | | - int ret; |
---|
| 1393 | + u8 *addr; |
---|
1397 | 1394 | |
---|
1398 | | - ret = fwnode_property_read_u8_array(acpi_fwnode_handle(adev), |
---|
1399 | | - "mac-address", mac, ETH_ALEN); |
---|
1400 | | - if (ret) |
---|
1401 | | - goto out; |
---|
1402 | | - |
---|
1403 | | - if (!is_valid_ether_addr(mac)) { |
---|
| 1395 | + addr = fwnode_get_mac_address(acpi_fwnode_handle(adev), mac, ETH_ALEN); |
---|
| 1396 | + if (!addr) { |
---|
1404 | 1397 | dev_err(dev, "MAC address invalid: %pM\n", mac); |
---|
1405 | | - ret = -EINVAL; |
---|
1406 | | - goto out; |
---|
| 1398 | + return -EINVAL; |
---|
1407 | 1399 | } |
---|
1408 | 1400 | |
---|
1409 | 1401 | dev_info(dev, "MAC address set to: %pM\n", mac); |
---|
1410 | 1402 | |
---|
1411 | | - memcpy(dst, mac, ETH_ALEN); |
---|
1412 | | -out: |
---|
1413 | | - return ret; |
---|
| 1403 | + ether_addr_copy(dst, mac); |
---|
| 1404 | + return 0; |
---|
1414 | 1405 | } |
---|
1415 | 1406 | |
---|
1416 | 1407 | /* Currently only sets the MAC address. */ |
---|
.. | .. |
---|
1447 | 1438 | return AE_OK; |
---|
1448 | 1439 | } |
---|
1449 | 1440 | |
---|
1450 | | - if (strncmp(string.pointer, bgx_sel, 4)) |
---|
| 1441 | + if (strncmp(string.pointer, bgx_sel, 4)) { |
---|
| 1442 | + kfree(string.pointer); |
---|
1451 | 1443 | return AE_OK; |
---|
| 1444 | + } |
---|
1452 | 1445 | |
---|
1453 | 1446 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1, |
---|
1454 | 1447 | bgx_acpi_register_phy, NULL, bgx, NULL); |
---|
.. | .. |
---|
1493 | 1486 | break; |
---|
1494 | 1487 | |
---|
1495 | 1488 | mac = of_get_mac_address(node); |
---|
1496 | | - if (mac) |
---|
| 1489 | + if (!IS_ERR(mac)) |
---|
1497 | 1490 | ether_addr_copy(bgx->lmac[lmac].mac, mac); |
---|
1498 | 1491 | |
---|
1499 | 1492 | SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev); |
---|