|
13 | 13 | */
|
14 | 14 |
|
15 | 15 | #include <linux/clk.h>
|
| 16 | +#include <linux/debugfs.h> |
16 | 17 | #include <linux/delay.h>
|
17 | 18 | #include <linux/io.h>
|
18 | 19 | #include <linux/kernel.h>
|
|
123 | 124 | #define ICM_PROTOCOL_DP 0x4
|
124 | 125 | #define ICM_PROTOCOL_SGMII 0x5
|
125 | 126 |
|
| 127 | +static const char *const xpsgtr_icm_str[] = { |
| 128 | + [ICM_PROTOCOL_PD] = "none", |
| 129 | + [ICM_PROTOCOL_PCIE] = "PCIe", |
| 130 | + [ICM_PROTOCOL_SATA] = "SATA", |
| 131 | + [ICM_PROTOCOL_USB] = "USB", |
| 132 | + [ICM_PROTOCOL_DP] = "DisplayPort", |
| 133 | + [ICM_PROTOCOL_SGMII] = "SGMII", |
| 134 | +}; |
| 135 | + |
126 | 136 | /* Test Mode common reset control parameters */
|
127 | 137 | #define TM_CMN_RST 0x10018
|
128 | 138 | #define TM_CMN_RST_EN 0x1
|
@@ -787,6 +797,34 @@ static struct phy *xpsgtr_xlate(struct device *dev,
|
787 | 797 | return ERR_PTR(-EINVAL);
|
788 | 798 | }
|
789 | 799 |
|
| 800 | +/* |
| 801 | + * DebugFS |
| 802 | + */ |
| 803 | + |
| 804 | +static int xpsgtr_status_read(struct seq_file *seq, void *data) |
| 805 | +{ |
| 806 | + struct device *dev = seq->private; |
| 807 | + struct xpsgtr_phy *gtr_phy = dev_get_drvdata(dev); |
| 808 | + struct clk *clk; |
| 809 | + u32 pll_status; |
| 810 | + |
| 811 | + mutex_lock(>r_phy->phy->mutex); |
| 812 | + pll_status = xpsgtr_read_phy(gtr_phy, L0_PLL_STATUS_READ_1); |
| 813 | + clk = gtr_phy->dev->clk[gtr_phy->refclk]; |
| 814 | + |
| 815 | + seq_printf(seq, "Lane: %u\n", gtr_phy->lane); |
| 816 | + seq_printf(seq, "Protocol: %s\n", |
| 817 | + xpsgtr_icm_str[gtr_phy->protocol]); |
| 818 | + seq_printf(seq, "Instance: %u\n", gtr_phy->instance); |
| 819 | + seq_printf(seq, "Reference clock: %u (%pC)\n", gtr_phy->refclk, clk); |
| 820 | + seq_printf(seq, "Reference rate: %lu\n", clk_get_rate(clk)); |
| 821 | + seq_printf(seq, "PLL locked: %s\n", |
| 822 | + pll_status & PLL_STATUS_LOCKED ? "yes" : "no"); |
| 823 | + |
| 824 | + mutex_unlock(>r_phy->phy->mutex); |
| 825 | + return 0; |
| 826 | +} |
| 827 | + |
790 | 828 | /*
|
791 | 829 | * Power Management
|
792 | 830 | */
|
@@ -936,6 +974,8 @@ static int xpsgtr_probe(struct platform_device *pdev)
|
936 | 974 |
|
937 | 975 | gtr_phy->phy = phy;
|
938 | 976 | phy_set_drvdata(phy, gtr_phy);
|
| 977 | + debugfs_create_devm_seqfile(&phy->dev, "status", phy->debugfs, |
| 978 | + xpsgtr_status_read); |
939 | 979 | }
|
940 | 980 |
|
941 | 981 | /* Register the PHY provider. */
|
|
0 commit comments