[PATCH i-g-t v7 47/48] lib/unigraf: Add helpers to get the current LT status

Louis Chauvet
2026-02-23T12:09:45Z

To ensure that the link training was correct, grab actual link
training status from unigraf.

Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
lib/unigraf/unigraf.c | 20 ++++++++++++++++++++
lib/unigraf/unigraf.h | 4 ++++
2 files changed, 24 insertions(+)

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index a18a90caad56..249eeaec2d05 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -834,6 +834,26 @@ int unigraf_get_max_lane_count(void)
return max_lanes;
}

+/**
+ * unigraf_get_lt_rate() - Get the current link training rate
+ *
+ * Returns: The current link training rate in units of 270 MHz.
+ */
+uint32_t unigraf_get_lt_rate(void)
+{
+ return unigraf_read_u32(TSI_DPRX_LT_RATE_R);
+}
+
+/**
+ * unigraf_get_lt_lane_count() - Get the current link training lane count
+ *
+ * Returns: The current number of lanes being used in link training.
+ */
+uint32_t unigraf_get_lt_lane_count(void)
+{
+ return unigraf_read_u32(TSI_DPRX_LT_LANE_COUNT_R);
+}
+
/**
* unigraf_set_max_link_rate() - Set the maximum link rate advertised to the DUT
* @rate: The maximum link rate to configure on the device. Actual value is
diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h
index 3cba15732daa..8032ef8e7fe6 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -98,4 +98,8 @@ int unigraf_get_max_link_rate(void);

int unigraf_rate_to_kbs(enum unigraf_rate rate);

+uint32_t unigraf_get_lt_rate(void);
+
+uint32_t unigraf_get_lt_lane_count(void);
+
#endif // UNIGRAF_H

--
2.52.0