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

Commit 91f5e546 authored by Hemant Kumar's avatar Hemant Kumar
Browse files

usb: phy-msm-qusb-v2: Add support to disable high speed chirping



If chirping sequence to detect high speed device fails to complete
device fails to enumerate. Add new call back to disable chirping
by writing 0x20 to QUSB2PHY_SQ_CTRL1 and 0x80 to QUSB2PHY_SQ_CTRL2.
With chirping disabled xhci host can re-enumerate device in full
speed mode.

Change-Id: Icadf4037d6eada63d7585791657db1bc8f6bad48
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent 669aeab5
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -136,7 +136,9 @@
			 0x230 /* QUSB2PHY_INTR_CTRL */
			 0x0a8 /* QUSB2PHY_PLL_CORE_INPUT_OVERRIDE */
			 0x254 /* QUSB2PHY_TEST1 */
			 0x198>; /* PLL_BIAS_CONTROL_2 */
			 0x198 /* PLL_BIAS_CONTROL_2 */
			 0x228 /* QUSB2PHY_SQ_CTRL1 */
			 0x22c>; /* QUSB2PHY_SQ_CTRL2 */

		qcom,qusb-phy-init-seq =
			/* <value reg_offset> */
@@ -421,7 +423,9 @@
			 0x230 /* QUSB2PHY_INTR_CTRL */
			 0x0a8 /* QUSB2PHY_PLL_CORE_INPUT_OVERRIDE */
			 0x254 /* QUSB2PHY_TEST1 */
			 0x198>; /* PLL_BIAS_CONTROL_2 */
			 0x198 /* PLL_BIAS_CONTROL_2 */
			 0x228 /* QUSB2PHY_SQ_CTRL1 */
			 0x22c>; /* QUSB2PHY_SQ_CTRL2 */

		qcom,qusb-phy-init-seq =
			/* <value reg_offset> */
+56 −0
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@

#define BIAS_CTRL_2_OVERRIDE_VAL	0x28

#define SQ_CTRL1_CHIRP_DISABLE		0x20
#define SQ_CTRL2_CHIRP_DISABLE		0x80

/* PERIPH_SS_PHY_REFGEN_NORTH_BG_CTRL register bits */
#define BANDGAP_BYPASS			BIT(0)

@@ -80,6 +83,8 @@ enum qusb_phy_reg {
	PLL_CORE_INPUT_OVERRIDE,
	TEST1,
	BIAS_CTRL_2,
	SQ_CTRL1,
	SQ_CTRL2,
	USB2_PHY_REG_MAX,
};

@@ -120,6 +125,10 @@ struct qusb_phy {
	struct regulator_desc	dpdm_rdesc;
	struct regulator_dev	*dpdm_rdev;

	u32			sq_ctrl1_default;
	u32			sq_ctrl2_default;
	bool			chirp_disable;

	/* emulation targets specific */
	void __iomem		*emu_phy_base;
	bool			emulation;
@@ -651,6 +660,52 @@ static int qusb_phy_notify_disconnect(struct usb_phy *phy,
	return 0;
}

static int qusb_phy_disable_chirp(struct usb_phy *phy, bool disable)
{
	struct qusb_phy *qphy = container_of(phy, struct qusb_phy, phy);
	int ret = 0;

	dev_dbg(phy->dev, "%s qphy chirp disable %d disable %d\n", __func__,
			qphy->chirp_disable, disable);

	mutex_lock(&qphy->lock);

	if (qphy->chirp_disable == disable) {
		ret = -EALREADY;
		goto done;
	}

	qphy->chirp_disable = disable;

	if (disable) {
		qphy->sq_ctrl1_default =
			readl_relaxed(qphy->base + qphy->phy_reg[SQ_CTRL1]);
		qphy->sq_ctrl2_default =
			readl_relaxed(qphy->base + qphy->phy_reg[SQ_CTRL2]);

		writel_relaxed(SQ_CTRL1_CHIRP_DISABLE,
				qphy->base + qphy->phy_reg[SQ_CTRL1]);
		readl_relaxed(qphy->base + qphy->phy_reg[SQ_CTRL1]);

		writel_relaxed(SQ_CTRL1_CHIRP_DISABLE,
				qphy->base + qphy->phy_reg[SQ_CTRL2]);
		readl_relaxed(qphy->base + qphy->phy_reg[SQ_CTRL2]);

		goto done;
	}

	writel_relaxed(qphy->sq_ctrl1_default,
			qphy->base + qphy->phy_reg[SQ_CTRL1]);
	readl_relaxed(qphy->base + qphy->phy_reg[SQ_CTRL1]);

	writel_relaxed(qphy->sq_ctrl2_default,
			qphy->base + qphy->phy_reg[SQ_CTRL2]);
	readl_relaxed(qphy->base + qphy->phy_reg[SQ_CTRL2]);
done:
	mutex_unlock(&qphy->lock);
	return ret;
}

static int qusb_phy_dpdm_regulator_enable(struct regulator_dev *rdev)
{
	int ret = 0;
@@ -1004,6 +1059,7 @@ static int qusb_phy_probe(struct platform_device *pdev)
	qphy->phy.type			= USB_PHY_TYPE_USB2;
	qphy->phy.notify_connect        = qusb_phy_notify_connect;
	qphy->phy.notify_disconnect     = qusb_phy_notify_disconnect;
	qphy->phy.disable_chirp		= qusb_phy_disable_chirp;

	ret = usb_add_phy_dev(&qphy->phy);
	if (ret)
+1 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ struct usb_phy {

	/* reset the PHY clocks */
	int     (*reset)(struct usb_phy *x);
	int	(*disable_chirp)(struct usb_phy *x, bool disable);
};

/**