power: smb5: Add moisture detection support for pmi632

Presence of moisture expedites the corrosion of Type-C/uUSB ID pins
due to constant DRP toggling. To reduce the effect of corrosion,
set DRP toggling duty cycle to 1% and suspend usb input on water
detection.

Use property MOISTURE_DETECTED to reflect moisture detection status.

Change-Id: I3bb41564cf67127ae2c0bb27089a1e8b5d722df6
Signed-off-by: Umang Agrawal <uagrawal@codeaurora.org>
diff --git a/drivers/power/supply/qcom/smb5-lib.h b/drivers/power/supply/qcom/smb5-lib.h
index e59b11b..8cd679a 100644
--- a/drivers/power/supply/qcom/smb5-lib.h
+++ b/drivers/power/supply/qcom/smb5-lib.h
@@ -18,6 +18,7 @@
 #include <linux/regulator/driver.h>
 #include <linux/regulator/consumer.h>
 #include <linux/extcon.h>
+#include <linux/alarmtimer.h>
 #include "storm-watch.h"
 
 enum print_reason {
@@ -68,6 +69,7 @@
 #define HW_LIMIT_VOTER			"HW_LIMIT_VOTER"
 #define FORCE_RECHARGE_VOTER		"FORCE_RECHARGE_VOTER"
 #define AICL_THRESHOLD_VOTER		"AICL_THRESHOLD_VOTER"
+#define MOISTURE_VOTER			"MOISTURE_VOTER"
 
 #define BOOST_BACK_STORM_COUNT	3
 #define WEAK_CHG_STORM_COUNT	8
@@ -98,6 +100,7 @@
 enum {
 	BOOST_BACK_WA			= BIT(0),
 	WEAK_ADAPTER_WA			= BIT(1),
+	MOISTURE_PROTECTION_WA		= BIT(2),
 };
 
 enum {
@@ -331,6 +334,7 @@
 	struct work_struct	bms_update_work;
 	struct work_struct	pl_update_work;
 	struct work_struct	jeita_update_work;
+	struct work_struct	moisture_protection_work;
 	struct delayed_work	ps_change_timeout_work;
 	struct delayed_work	clear_hdc_work;
 	struct delayed_work	icl_change_work;
@@ -338,6 +342,9 @@
 	struct delayed_work	uusb_otg_work;
 	struct delayed_work	bb_removal_work;
 
+	/* alarm */
+	struct alarm		moisture_protection_alarm;
+
 	/* pd */
 	int			voltage_min_uv;
 	int			voltage_max_uv;
@@ -386,6 +393,8 @@
 	int			aicl_cont_threshold_mv;
 	int			default_aicl_cont_threshold_mv;
 	bool			aicl_max_reached;
+	bool			moisture_present;
+	bool			moisture_protection_enabled;
 
 	/* workaround flag */
 	u32			wa_flags;