Skip to content

Commit 04490b6

Browse files
Sean Andersonvinodkoul
authored andcommitted
phy: zynqmp: Add debugfs support
Add support for printing some basic status information to debugfs. This is helpful when debugging phy consumers to make sure they are configuring the phy appropriately. Signed-off-by: Sean Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent d79c684 commit 04490b6

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

drivers/phy/xilinx/phy-zynqmp.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#include <linux/clk.h>
16+
#include <linux/debugfs.h>
1617
#include <linux/delay.h>
1718
#include <linux/io.h>
1819
#include <linux/kernel.h>
@@ -123,6 +124,15 @@
123124
#define ICM_PROTOCOL_DP 0x4
124125
#define ICM_PROTOCOL_SGMII 0x5
125126

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+
126136
/* Test Mode common reset control parameters */
127137
#define TM_CMN_RST 0x10018
128138
#define TM_CMN_RST_EN 0x1
@@ -787,6 +797,34 @@ static struct phy *xpsgtr_xlate(struct device *dev,
787797
return ERR_PTR(-EINVAL);
788798
}
789799

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(&gtr_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(&gtr_phy->phy->mutex);
825+
return 0;
826+
}
827+
790828
/*
791829
* Power Management
792830
*/
@@ -936,6 +974,8 @@ static int xpsgtr_probe(struct platform_device *pdev)
936974

937975
gtr_phy->phy = phy;
938976
phy_set_drvdata(phy, gtr_phy);
977+
debugfs_create_devm_seqfile(&phy->dev, "status", phy->debugfs,
978+
xpsgtr_status_read);
939979
}
940980

941981
/* Register the PHY provider. */

0 commit comments

Comments
 (0)