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

Commit 31cc9348 authored by Umang Agrawal's avatar Umang Agrawal
Browse files

power: smb5: Enable host mode VBUS handling for uUSB connector type



As per the new design the entity notifying extcon is expected to
enable/disable the VBUS in OTG mode, this applies for micro-USB and
non-PD typeC design where the PMIC drivers does the notification.

Add control to smb driver for enabling/disabling VBUS regulator on
host mode detection for uUSB and non-PD TypeC design.

Change-Id: I704982c6cab9b137a764ebaf6daa68f8f3de96da
Signed-off-by: default avatarUmang Agrawal <uagrawal@codeaurora.org>
parent 832d34e5
Loading
Loading
Loading
Loading
+26 −14
Original line number Diff line number Diff line
@@ -1599,6 +1599,8 @@ static int smb5_configure_micro_usb(struct smb_charger *chg)
{
	int rc;

	/* For micro USB connector, use extcon by default */
	chg->use_extcon = true;
	chg->pd_not_supported = true;

	rc = smblib_masked_write(chg, TYPE_C_INTERRUPT_EN_CFG_2_REG,
@@ -2640,20 +2642,6 @@ static int smb5_probe(struct platform_device *pdev)
	/* set driver data before resources request it */
	platform_set_drvdata(pdev, chip);

	rc = smb5_init_vbus_regulator(chip);
	if (rc < 0) {
		pr_err("Couldn't initialize vbus regulator rc=%d\n",
			rc);
		goto cleanup;
	}

	rc = smb5_init_vconn_regulator(chip);
	if (rc < 0) {
		pr_err("Couldn't initialize vconn regulator rc=%d\n",
				rc);
		goto cleanup;
	}

	/* extcon registration */
	chg->extcon = devm_extcon_dev_allocate(chg->dev, smblib_extcon_cable);
	if (IS_ERR(chg->extcon)) {
@@ -2676,6 +2664,30 @@ static int smb5_probe(struct platform_device *pdev)
		goto cleanup;
	}

	/*
	 * VBUS regulator enablement/disablement for host mode is handled
	 * by USB-PD driver only. For micro-USB and non-PD typeC designs,
	 * the VBUS regulator is enabled/disabled by the smb driver itself
	 * before sending extcon notifications.
	 * Hence, register vbus and vconn regulators for PD supported designs
	 * only.
	 */
	if (!chg->pd_not_supported) {
		rc = smb5_init_vbus_regulator(chip);
		if (rc < 0) {
			pr_err("Couldn't initialize vbus regulator rc=%d\n",
				rc);
			goto cleanup;
		}

		rc = smb5_init_vconn_regulator(chip);
		if (rc < 0) {
			pr_err("Couldn't initialize vconn regulator rc=%d\n",
				rc);
			goto cleanup;
		}
	}

	switch (chg->smb_version) {
	case PM8150B_SUBTYPE:
	case PM6150_SUBTYPE:
+24 −3
Original line number Diff line number Diff line
@@ -224,8 +224,30 @@ static void smblib_notify_device_mode(struct smb_charger *chg, bool enable)

static void smblib_notify_usb_host(struct smb_charger *chg, bool enable)
{
	if (enable)
	int rc = 0;

	if (enable) {
		smblib_dbg(chg, PR_OTG, "enabling VBUS in OTG mode\n");
		rc = smblib_masked_write(chg, DCDC_CMD_OTG_REG,
					OTG_EN_BIT, OTG_EN_BIT);
		if (rc < 0) {
			smblib_err(chg,
				"Couldn't enable VBUS in OTG mode rc=%d\n", rc);
			return;
		}

		smblib_notify_extcon_props(chg, EXTCON_USB_HOST);
	} else {
		smblib_dbg(chg, PR_OTG, "disabling VBUS in OTG mode\n");
		rc = smblib_masked_write(chg, DCDC_CMD_OTG_REG,
					OTG_EN_BIT, 0);
		if (rc < 0) {
			smblib_err(chg,
				"Couldn't disable VBUS in OTG mode rc=%d\n",
				rc);
			return;
		}
	}

	extcon_set_state_sync(chg->extcon, EXTCON_USB_HOST, enable);
}
@@ -3684,8 +3706,7 @@ static void smblib_handle_apsd_done(struct smb_charger *chg, bool rising)
	case SDP_CHARGER_BIT:
	case CDP_CHARGER_BIT:
	case FLOAT_CHARGER_BIT:
		if ((chg->connector_type == POWER_SUPPLY_CONNECTOR_MICRO_USB)
				|| chg->use_extcon)
		if (chg->use_extcon)
			smblib_notify_device_mode(chg, true);
		break;
	case OCP_CHARGER_BIT: