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

Commit 365a1743 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: dwc3: Add support to force speed to ssp"

parents 96103880 8fc3d34f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3258,6 +3258,8 @@ static ssize_t speed_store(struct device *dev, struct device_attribute *attr,
		req_speed = USB_SPEED_HIGH;
	else if (sysfs_streq(buf, "super"))
		req_speed = USB_SPEED_SUPER;
	else if (sysfs_streq(buf, "ssp"))
		req_speed = USB_SPEED_SUPER_PLUS;
	else
		return -EINVAL;

+57 −12
Original line number Diff line number Diff line
@@ -419,9 +419,23 @@ static int dwc3_ep0_handle_u1(struct dwc3 *dwc, enum usb_device_state state,
			(dwc->speed != DWC3_DSTS_SUPERSPEED_PLUS))
		return -EINVAL;

	if (dwc->usb3_u1u2_disable && !enable_dwc3_u1u2)
	/* Ignore all other checks if u1/u2 is enabled from user */
	if (enable_dwc3_u1u2)
		goto enable_u1;

	/*
	 * STAR: "9001276244: LFPS Handshake Interoperability Issues"
	 * has two part workaround, first part is to disable u1/u2
	 * in case of SSP to avoid interoperability issues.
	 */
	if (dwc->revision == DWC3_USB31_REVISION_170A &&
		(dwc->speed == DWC3_DSTS_SUPERSPEED_PLUS))
		return -EINVAL;

	if (dwc->usb3_u1u2_disable)
		return -EINVAL;

enable_u1:
	reg = dwc3_readl(dwc->regs, DWC3_DCTL);
	if (set)
		reg |= DWC3_DCTL_INITU1ENA;
@@ -444,9 +458,23 @@ static int dwc3_ep0_handle_u2(struct dwc3 *dwc, enum usb_device_state state,
			(dwc->speed != DWC3_DSTS_SUPERSPEED_PLUS))
		return -EINVAL;

	if (dwc->usb3_u1u2_disable && !enable_dwc3_u1u2)
	/* Ignore all other checks if u1/u2 is enabled from user */
	if (enable_dwc3_u1u2)
		goto enable_u2;

	/*
	 * STAR: "9001276244: LFPS Handshake Interoperability Issues"
	 * has two part workaround, first part is to disable u1/u2
	 * in case of SSP to avoid interoperability issues.
	 */
	if (dwc->revision == DWC3_USB31_REVISION_170A &&
		(dwc->speed == DWC3_DSTS_SUPERSPEED_PLUS))
		return -EINVAL;

	if (dwc->usb3_u1u2_disable)
		return -EINVAL;

enable_u2:
	reg = dwc3_readl(dwc->regs, DWC3_DCTL);
	if (set)
		reg |= DWC3_DCTL_INITU2ENA;
@@ -714,7 +742,25 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
				usb_gadget_set_state(&dwc->gadget,
						USB_STATE_CONFIGURED);

			if (!dwc->usb3_u1u2_disable || enable_dwc3_u1u2) {
			/*
			 * Ignore all other checks if u1/u2 is enabled
			 * from user
			 */
			if (enable_dwc3_u1u2)
				goto enable_u1u2;
			/*
			 * STAR:"9001276244: LFPS Handshake Interoperability
			 * Issues" has two part workaround, first part is to
			 * disable u1/u2 in case of SSP to avoid
			 * interoperability issues.
			 */
			if (dwc->revision == DWC3_USB31_REVISION_170A &&
				(dwc->speed == DWC3_DSTS_SUPERSPEED_PLUS))
				break;

			if (dwc->usb3_u1u2_disable)
				break;
enable_u1u2:
			/*
			 * Enable transition to U1/U2 state when
			 * nothing is pending from application.
@@ -724,7 +770,6 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
						DWC3_DCTL_ACCEPTU2ENA);
			dwc3_writel(dwc->regs, DWC3_DCTL, reg);
		}
		}
		break;

	case USB_STATE_CONFIGURED:
+39 −0
Original line number Diff line number Diff line
@@ -28,6 +28,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)
@@ -67,6 +68,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 */
@@ -111,6 +117,11 @@ struct msm_hsphy {
	int			emu_init_seq_len;
	int			*emu_dcm_reset_seq;
	int			emu_dcm_reset_seq_len;

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

static void msm_hsphy_enable_clocks(struct msm_hsphy *phy, bool on)
@@ -398,6 +409,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;

@@ -593,6 +621,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;
@@ -800,6 +835,8 @@ static int msm_hsphy_probe(struct platform_device *pdev)
		return ret;
	}

	msm_hsphy_create_debugfs(phy);

	return 0;

err_ret:
@@ -813,6 +850,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);