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

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

Merge "power: smblite-lib/smb5-lib: Fix partner registration for microusb"

parents 7f439aa4 a0031710
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -6574,6 +6574,10 @@ irqreturn_t smb5_typec_attach_detach_irq_handler(int irq, void *data)
	bool attached = false;
	int rc;

	/* IRQ not expected to be executed for uUSB, return */
	if (chg->connector_type == QTI_POWER_SUPPLY_CONNECTOR_MICRO_USB)
		return IRQ_HANDLED;

	smblib_dbg(chg, PR_INTERRUPT, "IRQ: %s\n", irq_data->name);

	rc = smblib_read(chg, TYPE_C_STATE_MACHINE_STATUS_REG, &stat);
@@ -7308,10 +7312,27 @@ static void smblib_uusb_otg_work(struct work_struct *work)
		goto out;
	}
	otg = !!(stat & U_USB_GROUND_NOVBUS_BIT);
	if (chg->otg_present != otg)
	if (chg->otg_present != otg) {
		if (otg) {
			/* otg cable inserted */
			if (chg->typec_port) {
				typec_partner_register(chg);
				typec_set_data_role(chg->typec_port,
							TYPEC_HOST);
				typec_set_pwr_role(chg->typec_port,
							TYPEC_SOURCE);
			}
		} else if (chg->typec_port) {
			/* otg cable removed */
			typec_set_data_role(chg->typec_port, TYPEC_DEVICE);
			typec_set_pwr_role(chg->typec_port, TYPEC_SINK);
			typec_partner_unregister(chg);
		}

		smblib_notify_usb_host(chg, otg);
	else
	} else {
		goto out;
	}

	chg->otg_present = otg;
	if (!otg)
+16 −0
Original line number Diff line number Diff line
@@ -2907,6 +2907,22 @@ irqreturn_t smblite_usb_id_irq_handler(int irq, void *data)

	smblite_lib_dbg(chg, PR_INTERRUPT, "IRQ: %s, id_state=%d\n",
					"usb-id-irq", id_state);
	if (id_state) {
		/*otg cable removed */
		if (chg->otg_present) {
			if (chg->typec_port) {
				typec_set_data_role(chg->typec_port,
							TYPEC_DEVICE);
				typec_set_pwr_role(chg->typec_port, TYPEC_SINK);
				typec_partner_unregister(chg);
			}
		}
	} else if (chg->typec_port) {
		/*otg cable inserted */
		typec_partner_register(chg);
		typec_set_data_role(chg->typec_port, TYPEC_HOST);
		typec_set_pwr_role(chg->typec_port, TYPEC_SOURCE);
	}

	smblite_lib_notify_usb_host(chg, !id_state);