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

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

Merge "power: smb5-lib: Check Type-C attached status in moisture detection"

parents b5d9bb29 9c83a371
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -4080,8 +4080,7 @@ irqreturn_t typec_or_rid_detection_change_irq_handler(int irq, void *data)
		goto out;
		goto out;
	}
	}


	/* liquid presence detected, to check further */
	if (!(stat & TYPEC_TCCDEBOUNCE_DONE_STATUS_BIT)
	if ((stat & TYPEC_WATER_DETECTION_STATUS_BIT)
			&& chg->lpd_stage == LPD_STAGE_NONE) {
			&& chg->lpd_stage == LPD_STAGE_NONE) {
		chg->lpd_stage = LPD_STAGE_FLOAT;
		chg->lpd_stage = LPD_STAGE_FLOAT;
		cancel_delayed_work_sync(&chg->lpd_ra_open_work);
		cancel_delayed_work_sync(&chg->lpd_ra_open_work);
@@ -4141,7 +4140,7 @@ irqreturn_t typec_attach_detach_irq_handler(int irq, void *data)
	}
	}


	if (stat & TYPEC_ATTACH_DETACH_STATE_BIT) {
	if (stat & TYPEC_ATTACH_DETACH_STATE_BIT) {
		chg->lpd_stage = LPD_STAGE_ATTACHED;
		chg->lpd_stage = LPD_STAGE_FLOAT_CANCEL;
		cancel_delayed_work_sync(&chg->lpd_ra_open_work);
		cancel_delayed_work_sync(&chg->lpd_ra_open_work);
		vote(chg->awake_votable, LPD_VOTER, false, 0);
		vote(chg->awake_votable, LPD_VOTER, false, 0);


@@ -4180,7 +4179,7 @@ irqreturn_t typec_attach_detach_irq_handler(int irq, void *data)
			chg->early_usb_attach = false;
			chg->early_usb_attach = false;
		}
		}


		chg->lpd_stage = LPD_STAGE_DETACHED;
		if (chg->lpd_stage == LPD_STAGE_FLOAT_CANCEL)
			schedule_delayed_work(&chg->lpd_detach_work,
			schedule_delayed_work(&chg->lpd_detach_work,
					msecs_to_jiffies(100));
					msecs_to_jiffies(100));
	}
	}
@@ -4677,8 +4676,9 @@ static void smblib_lpd_ra_open_work(struct work_struct *work)
		goto out;
		goto out;
	}
	}


	/* double check water detection status bit */
	/* quit if moisture status is gone or in attached state */
	if (!(stat & TYPEC_WATER_DETECTION_STATUS_BIT)) {
	if (!(stat & TYPEC_WATER_DETECTION_STATUS_BIT)
			|| (stat & TYPEC_TCCDEBOUNCE_DONE_STATUS_BIT)) {
		chg->lpd_stage = LPD_STAGE_NONE;
		chg->lpd_stage = LPD_STAGE_NONE;
		goto out;
		goto out;
	}
	}
@@ -4749,7 +4749,7 @@ static void smblib_lpd_detach_work(struct work_struct *work)
	struct smb_charger *chg = container_of(work, struct smb_charger,
	struct smb_charger *chg = container_of(work, struct smb_charger,
							lpd_detach_work.work);
							lpd_detach_work.work);


	if (chg->lpd_stage == LPD_STAGE_DETACHED)
	if (chg->lpd_stage == LPD_STAGE_FLOAT_CANCEL)
		chg->lpd_stage = LPD_STAGE_NONE;
		chg->lpd_stage = LPD_STAGE_NONE;
}
}


+6 −2
Original line number Original line Diff line number Diff line
@@ -204,11 +204,15 @@ enum lpd_reason {
	LPD_FLOATING_CABLE,
	LPD_FLOATING_CABLE,
};
};


/* Following states are applicable only for floating cable during LPD */
enum lpd_stage {
enum lpd_stage {
	/* initial stage */
	LPD_STAGE_NONE,
	LPD_STAGE_NONE,
	/* started and ongoing */
	LPD_STAGE_FLOAT,
	LPD_STAGE_FLOAT,
	LPD_STAGE_ATTACHED,
	/* cancel if started,  or don't start */
	LPD_STAGE_DETACHED,
	LPD_STAGE_FLOAT_CANCEL,
	/* confirmed and mitigation measures taken for 60 s */
	LPD_STAGE_COMMIT,
	LPD_STAGE_COMMIT,
};
};


+1 −0
Original line number Original line Diff line number Diff line
@@ -328,6 +328,7 @@ enum {
#define TYPEC_WATER_DETECTION_STATUS_BIT	BIT(7)
#define TYPEC_WATER_DETECTION_STATUS_BIT	BIT(7)
#define SNK_SRC_MODE_BIT			BIT(6)
#define SNK_SRC_MODE_BIT			BIT(6)
#define TYPEC_VBUS_ERROR_STATUS_BIT		BIT(4)
#define TYPEC_VBUS_ERROR_STATUS_BIT		BIT(4)
#define TYPEC_TCCDEBOUNCE_DONE_STATUS_BIT	BIT(3)
#define CC_ORIENTATION_BIT			BIT(1)
#define CC_ORIENTATION_BIT			BIT(1)
#define CC_ATTACHED_BIT				BIT(0)
#define CC_ATTACHED_BIT				BIT(0)