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

Commit 7f8ab566 authored by Kavya Nunna's avatar Kavya Nunna
Browse files

power: smblite-lib/smb5-lib: Add partner registration for microusb otg



Add partner registration for otg to provide UX. USB_HAL expects
power_role and data_role to be updated for the notification to UI.
Update power_role and data_role for microusb otg.

Change-Id: I741df638e18a400c862845bddd5bb19130adecd7
Signed-off-by: default avatarKavya Nunna <knunna@codeaurora.org>
parent 97ccfd4c
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -7225,10 +7225,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);