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

Commit 7bd947be authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: dwc3-msm: Add orientation setting capablity via sysfs"

parents 2fe5e492 70213109
Loading
Loading
Loading
Loading
+36 −2
Original line number Original line Diff line number Diff line
@@ -345,6 +345,7 @@ struct dwc3_msm {


	u64			dummy_gsi_db;
	u64			dummy_gsi_db;
	dma_addr_t		dummy_gsi_db_dma;
	dma_addr_t		dummy_gsi_db_dma;
	int			orientation_override;
};
};


#define USB_HSPHY_3P3_VOL_MIN		3050000 /* uV */
#define USB_HSPHY_3P3_VOL_MIN		3050000 /* uV */
@@ -2692,9 +2693,11 @@ static int dwc3_msm_resume(struct dwc3_msm *mdwc)
	if (dwc->maximum_speed >= USB_SPEED_SUPER &&
	if (dwc->maximum_speed >= USB_SPEED_SUPER &&
			mdwc->lpm_flags & MDWC3_SS_PHY_SUSPEND) {
			mdwc->lpm_flags & MDWC3_SS_PHY_SUSPEND) {
		mdwc->ss_phy->flags &= ~(PHY_LANE_A | PHY_LANE_B);
		mdwc->ss_phy->flags &= ~(PHY_LANE_A | PHY_LANE_B);
		if (mdwc->typec_orientation == ORIENTATION_CC1)
		if (mdwc->orientation_override)
			mdwc->ss_phy->flags |= mdwc->orientation_override;
		else if (mdwc->typec_orientation == ORIENTATION_CC1)
			mdwc->ss_phy->flags |= PHY_LANE_A;
			mdwc->ss_phy->flags |= PHY_LANE_A;
		if (mdwc->typec_orientation == ORIENTATION_CC2)
		else if (mdwc->typec_orientation == ORIENTATION_CC2)
			mdwc->ss_phy->flags |= PHY_LANE_B;
			mdwc->ss_phy->flags |= PHY_LANE_B;
		usb_phy_set_suspend(mdwc->ss_phy, 0);
		usb_phy_set_suspend(mdwc->ss_phy, 0);
		mdwc->ss_phy->flags &= ~DEVICE_IN_SS_MODE;
		mdwc->ss_phy->flags &= ~DEVICE_IN_SS_MODE;
@@ -3253,6 +3256,36 @@ static int dwc3_msm_extcon_register(struct dwc3_msm *mdwc)
	return 0;
	return 0;
}
}


static ssize_t orientation_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	struct dwc3_msm *mdwc = dev_get_drvdata(dev);

	if (mdwc->orientation_override == PHY_LANE_A)
		return scnprintf(buf, PAGE_SIZE, "A\n");
	if (mdwc->orientation_override == PHY_LANE_B)
		return scnprintf(buf, PAGE_SIZE, "B\n");

	return scnprintf(buf, PAGE_SIZE, "none\n");
}

static ssize_t orientation_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{
	struct dwc3_msm *mdwc = dev_get_drvdata(dev);

	if (sysfs_streq(buf, "A"))
		mdwc->orientation_override = PHY_LANE_A;
	else if (sysfs_streq(buf, "B"))
		mdwc->orientation_override = PHY_LANE_B;
	else
		mdwc->orientation_override = ORIENTATION_NONE;

	return count;
}

static DEVICE_ATTR_RW(orientation);

static ssize_t mode_show(struct device *dev, struct device_attribute *attr,
static ssize_t mode_show(struct device *dev, struct device_attribute *attr,
		char *buf)
		char *buf)
{
{
@@ -3807,6 +3840,7 @@ static int dwc3_msm_probe(struct platform_device *pdev)
		dwc3_ext_event_notify(mdwc);
		dwc3_ext_event_notify(mdwc);
	}
	}


	device_create_file(&pdev->dev, &dev_attr_orientation);
	device_create_file(&pdev->dev, &dev_attr_mode);
	device_create_file(&pdev->dev, &dev_attr_mode);
	device_create_file(&pdev->dev, &dev_attr_speed);
	device_create_file(&pdev->dev, &dev_attr_speed);
	device_create_file(&pdev->dev, &dev_attr_usb_compliance_mode);
	device_create_file(&pdev->dev, &dev_attr_usb_compliance_mode);