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

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

Merge "ucsi: ucsi_glink: notify partner information"

parents 4a43d056 409af606
Loading
Loading
Loading
Loading
+39 −10
Original line number Diff line number Diff line
@@ -365,6 +365,44 @@ static void msm_ssphy_qmp_setmode(struct msm_ssphy_qmp *phy, u32 mode)
	readl_relaxed(phy->base + phy->phy_reg[USB3_DP_COM_PHY_MODE_CTRL]);
}

static void usb_qmp_update_hw_portselect(struct msm_ssphy_qmp *phy)
{
	struct pinctrl		*portselect_pinctrl;
	struct pinctrl_state	*portselect_state;

	if (phy->phy.dev->pins) {
		portselect_pinctrl = phy->phy.dev->pins->p;
		portselect_state = phy->phy.dev->pins->default_state;
	} else {
		portselect_pinctrl = pinctrl_get(phy->phy.dev);
		if (IS_ERR_OR_NULL(portselect_pinctrl)) {
			dev_dbg(phy->phy.dev, "failed to get pinctrl\n");
			return;
		}

		portselect_state =
			pinctrl_lookup_state(portselect_pinctrl, "portselect");
		if (IS_ERR_OR_NULL(portselect_state)) {
			dev_dbg(phy->phy.dev,
				"failed to find portselect state\n");
			pinctrl_put(portselect_pinctrl);
			return;
		}
	}

	dev_dbg(phy->phy.dev, "use hw port select\n");

	writel_relaxed(0x01,
		phy->base + phy->phy_reg[USB3_DP_COM_SW_RESET]);

	pinctrl_select_state(portselect_pinctrl, portselect_state);

	writel_relaxed(0x00,
		phy->base + phy->phy_reg[USB3_DP_COM_SW_RESET]);

	if (!phy->phy.dev->pins)
		pinctrl_put(portselect_pinctrl);
}

static void usb_qmp_update_portselect_phymode(struct msm_ssphy_qmp *phy)
{
@@ -382,16 +420,7 @@ static void usb_qmp_update_portselect_phymode(struct msm_ssphy_qmp *phy)

	switch (phy->phy_type) {
	case USB3_AND_DP:
		if (phy->phy.dev->pins) {
			writel_relaxed(0x01,
				phy->base + phy->phy_reg[USB3_DP_COM_SW_RESET]);

			pinctrl_select_state(phy->phy.dev->pins->p,
					phy->phy.dev->pins->default_state);

			writel_relaxed(0x00,
				phy->base + phy->phy_reg[USB3_DP_COM_SW_RESET]);
		}
		usb_qmp_update_hw_portselect(phy);

		/* override hardware control for reset of qmp phy */
		writel_relaxed(SW_DPPHY_RESET_MUX | SW_DPPHY_RESET |
+18 −1
Original line number Diff line number Diff line
@@ -363,7 +363,7 @@ static void ucsi_qti_notify_work(struct work_struct *work)
static void ucsi_qti_notify(struct ucsi_dev *udev, unsigned int offset,
			    struct ucsi_connector_status *status)
{
	u8 conn_partner_type;
	u8 conn_partner_type, conn_partner_flag;
	bool cmd_requested;

	mutex_lock(&udev->notify_lock);
@@ -372,6 +372,10 @@ static void ucsi_qti_notify(struct ucsi_dev *udev, unsigned int offset,

	if (cmd_requested && offset == UCSI_MESSAGE_IN) {
		cancel_work_sync(&udev->notify_work);

		udev->constat_info.partner_usb = false;
		udev->constat_info.partner_alternate_mode = false;

		conn_partner_type = UCSI_CONSTAT_PARTNER_TYPE(status->flags);

		switch (conn_partner_type) {
@@ -381,11 +385,24 @@ static void ucsi_qti_notify(struct ucsi_dev *udev, unsigned int offset,
		case UCSI_CONSTAT_PARTNER_TYPE_DEBUG:
			udev->constat_info.acc = TYPEC_ACCESSORY_DEBUG;
			break;
		case UCSI_CONSTAT_PARTNER_TYPE_UFP:
		case UCSI_CONSTAT_PARTNER_TYPE_CABLE:
		case UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP:
		case UCSI_CONSTAT_PARTNER_TYPE_DFP:
			udev->constat_info.partner_usb = true;
			/* fallthrough */
		default:
			udev->constat_info.acc = TYPEC_ACCESSORY_NONE;
			break;
		}

		conn_partner_flag = UCSI_CONSTAT_PARTNER_FLAGS(status->flags);
		if (conn_partner_flag & UCSI_CONSTAT_PARTNER_FLAG_USB)
			udev->constat_info.partner_usb = true;

		if (conn_partner_flag & UCSI_CONSTAT_PARTNER_FLAG_ALT_MODE)
			udev->constat_info.partner_alternate_mode = true;

		schedule_work(&udev->notify_work);
	}
}
+2 −0
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@

struct ucsi_glink_constat_info {
	enum typec_accessory acc;
	bool partner_usb;
	bool partner_alternate_mode;
};

struct notifier_block;