48 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2 3#ifndef OPEN_ALLIANCE_HELPERS_H4#define OPEN_ALLIANCE_HELPERS_H5 6/*7 * These defines reflect the TDR (Time Delay Reflection) diagnostic feature8 * for 1000BASE-T1 automotive Ethernet PHYs as specified by the OPEN Alliance.9 *10 * The register values are part of the HDD.TDR register, which provides11 * information about the cable status and faults. The exact register offset12 * is device-specific and should be provided by the driver.13 */14#define OA_1000BT1_HDD_TDR_ACTIVATION_MASK GENMASK(1, 0)15#define OA_1000BT1_HDD_TDR_ACTIVATION_OFF 116#define OA_1000BT1_HDD_TDR_ACTIVATION_ON 217 18#define OA_1000BT1_HDD_TDR_STATUS_MASK GENMASK(7, 4)19#define OA_1000BT1_HDD_TDR_STATUS_SHORT 320#define OA_1000BT1_HDD_TDR_STATUS_OPEN 621#define OA_1000BT1_HDD_TDR_STATUS_NOISE 522#define OA_1000BT1_HDD_TDR_STATUS_CABLE_OK 723#define OA_1000BT1_HDD_TDR_STATUS_TEST_IN_PROGRESS 824#define OA_1000BT1_HDD_TDR_STATUS_TEST_NOT_POSSIBLE 1325 26/*27 * OA_1000BT1_HDD_TDR_DISTANCE_MASK:28 * This mask is used to extract the distance to the first/main fault29 * detected by the TDR feature. Each bit represents an approximate distance30 * of 1 meter, ranging from 0 to 31 meters. The exact interpretation of the31 * bits may vary, but generally:32 * 000000 = no error33 * 000001 = error about 0-1m away34 * 000010 = error between 1-2m away35 * ...36 * 011111 = error about 30-31m away37 * 111111 = resolution not possible / out of distance38 */39#define OA_1000BT1_HDD_TDR_DISTANCE_MASK GENMASK(13, 8)40#define OA_1000BT1_HDD_TDR_DISTANCE_NO_ERROR 041#define OA_1000BT1_HDD_TDR_DISTANCE_RESOLUTION_NOT_POSSIBLE 0x3f42 43int oa_1000bt1_get_ethtool_cable_result_code(u16 reg_value);44int oa_1000bt1_get_tdr_distance(u16 reg_value);45 46#endif /* OPEN_ALLIANCE_HELPERS_H */47 48