open_alliance_helpers.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef OPEN_ALLIANCE_HELPERS_H
  3. #define OPEN_ALLIANCE_HELPERS_H
  4. /*
  5. * These defines reflect the TDR (Time Delay Reflection) diagnostic feature
  6. * for 1000BASE-T1 automotive Ethernet PHYs as specified by the OPEN Alliance.
  7. *
  8. * The register values are part of the HDD.TDR register, which provides
  9. * information about the cable status and faults. The exact register offset
  10. * is device-specific and should be provided by the driver.
  11. */
  12. #define OA_1000BT1_HDD_TDR_ACTIVATION_MASK GENMASK(1, 0)
  13. #define OA_1000BT1_HDD_TDR_ACTIVATION_OFF 1
  14. #define OA_1000BT1_HDD_TDR_ACTIVATION_ON 2
  15. #define OA_1000BT1_HDD_TDR_STATUS_MASK GENMASK(7, 4)
  16. #define OA_1000BT1_HDD_TDR_STATUS_SHORT 3
  17. #define OA_1000BT1_HDD_TDR_STATUS_OPEN 6
  18. #define OA_1000BT1_HDD_TDR_STATUS_NOISE 5
  19. #define OA_1000BT1_HDD_TDR_STATUS_CABLE_OK 7
  20. #define OA_1000BT1_HDD_TDR_STATUS_TEST_IN_PROGRESS 8
  21. #define OA_1000BT1_HDD_TDR_STATUS_TEST_NOT_POSSIBLE 13
  22. /*
  23. * OA_1000BT1_HDD_TDR_DISTANCE_MASK:
  24. * This mask is used to extract the distance to the first/main fault
  25. * detected by the TDR feature. Each bit represents an approximate distance
  26. * of 1 meter, ranging from 0 to 31 meters. The exact interpretation of the
  27. * bits may vary, but generally:
  28. * 000000 = no error
  29. * 000001 = error about 0-1m away
  30. * 000010 = error between 1-2m away
  31. * ...
  32. * 011111 = error about 30-31m away
  33. * 111111 = resolution not possible / out of distance
  34. */
  35. #define OA_1000BT1_HDD_TDR_DISTANCE_MASK GENMASK(13, 8)
  36. #define OA_1000BT1_HDD_TDR_DISTANCE_NO_ERROR 0
  37. #define OA_1000BT1_HDD_TDR_DISTANCE_RESOLUTION_NOT_POSSIBLE 0x3f
  38. int oa_1000bt1_get_ethtool_cable_result_code(u16 reg_value);
  39. int oa_1000bt1_get_tdr_distance(u16 reg_value);
  40. #endif /* OPEN_ALLIANCE_HELPERS_H */