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

Commit 07be0b4a authored by Harry Yang's avatar Harry Yang Committed by Guru Das Srinagesh
Browse files

power: smb5: Enable charging with Type-C headset+charger adapter



Currently charging is disabled with Type-C headset+charger
adapter. Enable charging and configure ICL to 500mA.

Change-Id: Iabecb5c11b17f1aba518790af97c45ea2e692bbd
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
Signed-off-by: default avatarSahil Chandna <chandna@codeaurora.org>
parent 93df147c
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -4854,6 +4854,11 @@ static void update_sw_icl_max(struct smb_charger *chg, int pst)
	if (chg->pd_active)
		return;

	if (chg->typec_mode == POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER) {
		vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, 500000);
		return;
	}

	/*
	 * HVDCP 2/3, handled separately
	 */
@@ -5138,6 +5143,14 @@ static void typec_src_insertion(struct smb_charger *chg)
		smblib_hvdcp_detect_try_enable(chg, true);
}

static void typec_ra_ra_insertion(struct smb_charger *chg)
{
	vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, 500000);
	vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0);
	chg->ok_to_pd = false;
	smblib_hvdcp_detect_enable(chg, true);
}

static void typec_sink_removal(struct smb_charger *chg)
{
	int rc;
@@ -5437,7 +5450,11 @@ irqreturn_t typec_attach_detach_irq_handler(int irq, void *data)
			return IRQ_HANDLED;
		}

		if (stat & SNK_SRC_MODE_BIT) {
		if (smblib_get_prop_dfp_mode(chg) ==
				POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER) {
			chg->sink_src_mode = AUDIO_ACCESS_MODE;
			typec_ra_ra_insertion(chg);
		} else if (stat & SNK_SRC_MODE_BIT) {
			if (smblib_src_lpd(chg))
				return IRQ_HANDLED;
			chg->sink_src_mode = SRC_MODE;
@@ -5453,6 +5470,7 @@ irqreturn_t typec_attach_detach_irq_handler(int irq, void *data)
			typec_sink_removal(chg);
			break;
		case SINK_MODE:
		case AUDIO_ACCESS_MODE:
			typec_src_removal(chg);
			break;
		case UNATTACHED_MODE:
+1 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ enum smb_mode {
enum sink_src_mode {
	SINK_MODE,
	SRC_MODE,
	AUDIO_ACCESS_MODE,
	UNATTACHED_MODE,
};