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

Commit cf067b80 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: qpnp-smbcharger: add support to control hvdcp3 detection dynamically"

parents 29506fb3 6e4945fa
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ struct smbchg_chip {
	bool				vbat_above_headroom;
	bool				force_aicl_rerun;
	bool				hvdcp3_supported;
	bool				allow_hvdcp3_detection;
	bool				restricted_charging;
	bool				skip_usb_suspend_for_fake_battery;
	bool				hvdcp_not_supported;
@@ -5104,6 +5105,30 @@ static int fake_insertion_removal(struct smbchg_chip *chip, bool insertion)
	return 0;
}

static void smbchg_handle_hvdcp3_disable(struct smbchg_chip *chip)
{
	enum power_supply_type usb_supply_type;
	char *usb_type_name = "NULL";

	if (chip->allow_hvdcp3_detection)
		return;

	chip->pulse_cnt = 0;

	if (is_hvdcp_present(chip)) {
		smbchg_change_usb_supply_type(chip,
			POWER_SUPPLY_TYPE_USB_HVDCP);
	} else if (is_usb_present(chip)) {
		read_usb_type(chip, &usb_type_name, &usb_supply_type);
		smbchg_change_usb_supply_type(chip, usb_supply_type);
		if (usb_supply_type == POWER_SUPPLY_TYPE_USB_DCP)
			schedule_delayed_work(&chip->hvdcp_det_work,
				msecs_to_jiffies(HVDCP_NOTIFY_MS));
	} else {
		smbchg_change_usb_supply_type(chip, POWER_SUPPLY_TYPE_UNKNOWN);
	}
}

static int smbchg_prepare_for_pulsing(struct smbchg_chip *chip)
{
	int rc = 0;
@@ -5320,6 +5345,9 @@ out:
		pr_smb(PR_MISC, "HVDCP removed\n");
		update_usb_status(chip, 0, 0);
	}

	smbchg_handle_hvdcp3_disable(chip);

	return rc;
}

@@ -5504,6 +5532,8 @@ static int smbchg_unprepare_for_pulsing_lite(struct smbchg_chip *chip)
	if (rc < 0)
		pr_err("Couldn't retract HVDCP ICL vote rc=%d\n", rc);

	smbchg_handle_hvdcp3_disable(chip);

	return rc;
}

@@ -5718,6 +5748,7 @@ static enum power_supply_property smbchg_battery_properties[] = {
	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED,
	POWER_SUPPLY_PROP_RERUN_AICL,
	POWER_SUPPLY_PROP_RESTRICTED_CHARGING,
	POWER_SUPPLY_PROP_ALLOW_HVDCP3,
};

static int smbchg_battery_set_property(struct power_supply *psy,
@@ -5795,6 +5826,12 @@ static int smbchg_battery_set_property(struct power_supply *psy,
		if (chip->typec_psy)
			update_typec_otg_status(chip, val->intval, false);
		break;
	case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
		if (chip->allow_hvdcp3_detection != val->intval) {
			chip->allow_hvdcp3_detection = !!val->intval;
			power_supply_changed(&chip->batt_psy);
		}
		break;
	default:
		return -EINVAL;
	}
@@ -5818,6 +5855,7 @@ static int smbchg_battery_is_writeable(struct power_supply *psy,
	case POWER_SUPPLY_PROP_DP_DM:
	case POWER_SUPPLY_PROP_RERUN_AICL:
	case POWER_SUPPLY_PROP_RESTRICTED_CHARGING:
	case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
		rc = 1;
		break;
	default:
@@ -5915,6 +5953,9 @@ static int smbchg_battery_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_INPUT_CURRENT_NOW:
		val->intval = smbchg_get_iusb(chip);
		break;
	case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
		val->intval = chip->allow_hvdcp3_detection;
		break;
	default:
		return -EINVAL;
	}
@@ -8134,6 +8175,7 @@ static int smbchg_probe(struct spmi_device *spmi)
		}
	}
	chip->psy_registered = true;
	chip->allow_hvdcp3_detection = true;

	if (chip->cfg_chg_led_support &&
			chip->schg_version == QPNP_SCHG_LITE) {