Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d8bd378 authored by Vamsi Krishna Samavedam's avatar Vamsi Krishna Samavedam Committed by Gerrit - the friendly Code Review server
Browse files

usb: phy: snps: Add debugfs support to tune tx compliance



Debugfs entries will be used to test various tx parameters such
as pre-emphasis and vref to tune the tx compliance and eye diagram.

Change-Id: I5f09c1525c862acfd004a6a0f3414947dcc1c602
Signed-off-by: default avatarVamsi Krishna Samavedam <vskrishn@codeaurora.org>
parent 5219be0f
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/regulator/machine.h>
#include <linux/usb/phy.h>
#include <linux/reset.h>
#include <linux/debugfs.h>

#define USB2_PHY_USB_PHY_UTMI_CTRL0		(0x3c)
#define OPMODE_MASK				(0x3 << 3)
@@ -59,6 +60,11 @@
#define USB2PHY_USB_PHY_RTUNE_SEL		(0xb4)
#define RTUNE_SEL				BIT(0)

#define TXPREEMPAMPTUNE0(x)			(x << 6)
#define TXPREEMPAMPTUNE0_MASK			(BIT(7) | BIT(6))
#define USB2PHY_USB_PHY_PARAMETER_OVERRIDE_X1	0x70
#define TXVREFTUNE0_MASK			0xF

#define USB_HSPHY_3P3_VOL_MIN			3050000 /* uV */
#define USB_HSPHY_3P3_VOL_MAX			3300000 /* uV */
#define USB_HSPHY_3P3_HPM_LOAD			16000	/* uA */
@@ -98,6 +104,11 @@ struct msm_hsphy {
	struct mutex		phy_lock;
	struct regulator_desc	dpdm_rdesc;
	struct regulator_dev	*dpdm_rdev;

	/* debugfs entries */
	struct dentry		*root;
	u8			txvref_tune0;
	u8			pre_emphasis;
};

static void msm_hsphy_enable_clocks(struct msm_hsphy *phy, bool on)
@@ -360,6 +371,23 @@ static int msm_hsphy_init(struct usb_phy *uphy)
		hsusb_phy_write_seq(phy->base, phy->param_override_seq,
				phy->param_override_seq_cnt, 0);

	if (phy->pre_emphasis) {
		u8 val = TXPREEMPAMPTUNE0(phy->pre_emphasis) &
				TXPREEMPAMPTUNE0_MASK;
		if (val)
			msm_usb_write_readback(phy->base,
				USB2PHY_USB_PHY_PARAMETER_OVERRIDE_X1,
				TXPREEMPAMPTUNE0_MASK, val);
	}

	if (phy->txvref_tune0) {
		u8 val = phy->txvref_tune0 & TXVREFTUNE0_MASK;

		msm_usb_write_readback(phy->base,
			USB2PHY_USB_PHY_PARAMETER_OVERRIDE_X1,
			TXVREFTUNE0_MASK, val);
	}

	if (phy->phy_rcal_reg) {
		rcal_code = readl_relaxed(phy->phy_rcal_reg) & phy->rcal_mask;

@@ -574,6 +602,13 @@ static int msm_hsphy_regulator_init(struct msm_hsphy *phy)
	return 0;
}

static void msm_hsphy_create_debugfs(struct msm_hsphy *phy)
{
	phy->root = debugfs_create_dir(dev_name(phy->phy.dev), NULL);
	debugfs_create_x8("pre_emphasis", 0644, phy->root, &phy->pre_emphasis);
	debugfs_create_x8("txvref_tune0", 0644, phy->root, &phy->txvref_tune0);
}

static int msm_hsphy_probe(struct platform_device *pdev)
{
	struct msm_hsphy *phy;
@@ -735,6 +770,8 @@ static int msm_hsphy_probe(struct platform_device *pdev)
		return ret;
	}

	msm_hsphy_create_debugfs(phy);

	return 0;

err_ret:
@@ -748,6 +785,8 @@ static int msm_hsphy_remove(struct platform_device *pdev)
	if (!phy)
		return 0;

	debugfs_remove_recursive(phy->root);

	usb_remove_phy(&phy->phy);
	clk_disable_unprepare(phy->ref_clk_src);