/*
 * Driver for the NXP PCA9468 battery charger.
 *
 * Copyright (C) 2018 NXP Semiconductor.
 * Copyright 2020 Google, LLC
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/err.h>
#include <linux/version.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/of_irq.h>
#include <linux/of_device.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/rtc.h>
#include <misc/gvotable.h>

#include "pca9468_regs.h"
#include "pca9468_charger.h"

#if defined (CONFIG_OF)
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#endif /* CONFIG_OF */

/* adc_gain bit[7:4] of reg 0x31 - 2's complement */
static int adc_gain[16] = { 0,  1,  2,  3,  4,  5,  6,  7,
			   -8, -7, -6, -5, -4, -3, -2, -1};

/* Timer definition */
#define PCA9468_VBATMIN_CHECK_T	1000	/* 1000ms */
#define PCA9468_CCMODE_CHECK1_T	5000	/* 10000ms -> 500ms */
#define PCA9468_CCMODE_CHECK2_T	5000	/* 5000ms */
#define PCA9468_CVMODE_CHECK_T 	10000	/* 10000ms */
#define PCA9468_ENABLE_DELAY_T	150	/* 150ms */
#define PCA9468_CVMODE_CHECK2_T	1000	/* 1000ms */
#define PCA9468_ENABLE_WLC_DELAY_T	300	/* 300ms */

/* Battery Threshold */
#define PCA9468_DC_VBAT_MIN		3400000 /* uV */
/* Input Current Limit default value */
#define PCA9468_IIN_CFG_DFT		2500000 /* uA*/
/* Charging Float Voltage default value */
#define PCA9468_VFLOAT_DFT		4350000	/* uV */
/* Charging Sub Float Voltage default value */
#define PCA9468_VFLOAT_SUB_DFT		5000000	/* 5000000uV */
/* Charging Float Voltage max voltage for comp */
#define PCA9468_COMP_VFLOAT_MAX		4450000	/* uV */

/* Sense Resistance default value */
#define PCA9468_SENSE_R_DFT		1	/* 10mOhm */
/* Switching Frequency default value */
#define PCA9468_FSW_CFG_DFT		3	/* 980KHz */
/* NTC threshold voltage default value */
#define PCA9468_NTC_TH_DFT		0	/* uV*/

/* Charging Done Condition */
#define PCA9468_IIN_DONE_DFT	500000		/* uA */
/* parallel charging done conditoin */
#define PCA9468_IIN_P_DONE	1000000		/* uA */
/* Parallel charging default threshold */
#define PCA9468_IIN_P_TH_DFT	4000000		/* uA */
/* Single charging default threshold */
#define PCA9468_IIN_S_TH_DFT	10000000	/* uA */

/* Maximum TA voltage threshold */
#define PCA9468_TA_MAX_VOL		9800000 /* uV */
/* Maximum TA current threshold, set to max(cc_max) / 2 */
#define PCA9468_TA_MAX_CUR		2600000	 /* uA */
/* Minimum TA current threshold */
#define PCA9468_TA_MIN_CUR		1000000	/* uA - PPS minimum current */

/* Minimum TA voltage threshold in Preset mode */
#define PCA9468_TA_MIN_VOL_PRESET	8000000	/* uV */
/* TA voltage threshold starting Adjust CC mode */
#define PCA9468_TA_MIN_VOL_CCADJ	8500000	/* 8000000uV --> 8500000uV */

#define PCA9468_TA_VOL_PRE_OFFSET	500000	 /* uV */
/* Adjust CC mode TA voltage step */
#define PCA9468_TA_VOL_STEP_ADJ_CC	40000	/* uV */
/* Pre CV mode TA voltage step */
#define PCA9468_TA_VOL_STEP_PRE_CV	20000	/* uV */

/* IIN_CC adc offset for accuracy */
#define PCA9468_IIN_ADC_OFFSET		20000	/* uA */
/* IIN_CC compensation offset */
#define PCA9468_IIN_CC_COMP_OFFSET	50000	/* uA */
/* IIN_CC compensation offset in Power Limit Mode(Constant Power) TA */
#define PCA9468_IIN_CC_COMP_OFFSET_CP	20000	/* uA */
/* TA maximum voltage that can support CC in Constant Power Mode */
#define PCA9468_TA_MAX_VOL_CP		9800000	/* 9760000uV --> 9800000uV */
/* Offset for cc_max / 2 */
#define PCA9468_IIN_MAX_OFFSET		0


/* maximum retry counter for restarting charging */
#define PCA9468_MAX_RETRY_CNT		3	/* retries */
/* TA IIN tolerance */
#define PCA9468_TA_IIN_OFFSET		100000	/* uA */
/* IIN_CC upper protection offset in Power Limit Mode TA */
#define PCA9468_IIN_CC_UPPER_OFFSET	50000	/* 50mA */

/* PD Message Voltage and Current Step */
#define PD_MSG_TA_VOL_STEP		20000	/* uV */
#define PD_MSG_TA_CUR_STEP		50000	/* uA */

/* Maximum WCRX voltage threshold */
#define PCA9468_WCRX_MAX_VOL		9750000 /* uV */
/* WCRX voltage Step */
#define WCRX_VOL_STEP			100000	/* uV */

#define PCA9468_OTV_MARGIN		12000	/* uV */

/* irdrop default limit */
#define PCA9468_IRDROP_LIMIT_CNT	3	/* tiers */
#define PCA9468_IRDROP_LIMIT_TIER1	105000	/* uV */
#define PCA9468_IRDROP_LIMIT_TIER2	75000	/* uV */
#define PCA9468_IRDROP_LIMIT_TIER3	0	/* uV */

/* Spread Spectrum default settings */
#define PCA9468_SC_CLK_DITHER_RATE_DEF	0	/* 25kHz */
#define PCA9468_SC_CLK_DITHER_LIMIT_DEF	0xF	/* 10% */

/* INT1 Register Buffer */
enum {
	REG_INT1,
	REG_INT1_MSK,
	REG_INT1_STS,
	REG_INT1_MAX
};

/* STS Register Buffer */
enum {
	REG_STS_A,
	REG_STS_B,
	REG_STS_C,
	REG_STS_D,
	REG_STS_MAX
};

/* Status */
enum {
	STS_MODE_CHG_LOOP,	/* TODO: There is no such thing */
	STS_MODE_VFLT_LOOP,
	STS_MODE_IIN_LOOP,
	STS_MODE_LOOP_INACTIVE,
	STS_MODE_CHG_DONE,
	STS_MODE_VIN_UVLO,
};

/* Timer ID */
enum {
	TIMER_ID_NONE,
	TIMER_VBATMIN_CHECK,
	TIMER_PRESET_DC,
	TIMER_PRESET_CONFIG,
	TIMER_CHECK_ACTIVE,
	TIMER_ADJUST_CCMODE,
	TIMER_CHECK_CCMODE,
	TIMER_ENTER_CVMODE,
	TIMER_CHECK_CVMODE, /* 8 */
	TIMER_PDMSG_SEND,   /* 9 */
	TIMER_ADJUST_TAVOL,
	TIMER_ADJUST_TACUR,
};


/* TA increment Type */
enum {
	INC_NONE,	/* No increment */
	INC_TA_VOL,	/* TA voltage increment */
	INC_TA_CUR,	/* TA current increment */
};

/* BATT info Type */
enum {
	BATT_CURRENT,
	BATT_VOLTAGE,
};

/* IIN offset as the switching frequency in uA*/
static int iin_fsw_cfg[16] = { 9990, 10540, 11010, 11520, 12000, 12520, 12990,
			      13470, 5460, 6050, 6580, 7150, 7670, 8230, 8720,
			      9260};


/* ------------------------------------------------------------------------ */

/* ADC Read function, return uV or uA */
int pca9468_read_adc(struct pca9468_charger *pca9468, u8 adc_ch)
{
	u8 reg_data[2];
	u16 raw_adc = 0;
	int conv_adc = -1;
	int ret;

	switch (adc_ch) {
	case ADCCH_VOUT:
		/* ~PCA9468_BIT_CH1_EN, PCA9468_REG_ADC_CFG, udelay(120) us */

		ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_STS_ADC_4,
				       reg_data, 2);
		if (ret < 0) {
			conv_adc = ret;
			goto error;
		}

		raw_adc = ((reg_data[1] & PCA9468_BIT_ADC_VOUT9_2) << 2) |
			  ((reg_data[0] & PCA9468_BIT_ADC_VOUT1_0) >> 6);
		conv_adc = raw_adc * VOUT_STEP;	/* unit - uV */
		break;

	case ADCCH_VIN:
		/* ~PCA9468_BIT_CH2_EN, PCA9468_REG_ADC_CFG, udelay(120) us */

		ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_STS_ADC_3,
				       reg_data, 2);
		if (ret < 0) {
			conv_adc = ret;
			goto error;
		}

		raw_adc = ((reg_data[1] & PCA9468_BIT_ADC_VIN9_4) << 4) |
			  ((reg_data[0] & PCA9468_BIT_ADC_VIN3_0) >> 4);
		conv_adc = raw_adc * VIN_STEP;	/* unit - uV */
		break;

	case ADCCH_VBAT:
		/* ~PCA9468_BIT_CH3_EN, PCA9468_REG_ADC_CFG, udelay(120) us */

		ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_STS_ADC_6,
				       reg_data, 2);
		if (ret < 0) {
			conv_adc = ret;
			goto error;
		}

		raw_adc = ((reg_data[1] & PCA9468_BIT_ADC_VBAT9_8) << 8) |
			  ((reg_data[0] & PCA9468_BIT_ADC_VBAT7_0) >> 0);
		conv_adc = raw_adc * VBAT_STEP; /* unit - uV */
		break;

	case ADCCH_IIN:
		/* ~PCA9468_BIT_CH5_EN, PCA9468_REG_ADC_CFG, udelay(120) us */

		ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_STS_ADC_1,
				       reg_data, 2);
		if (ret < 0) {
			conv_adc = ret;
			goto error;
		}

		raw_adc = ((reg_data[1] & PCA9468_BIT_ADC_IIN9_8) << 8) |
			  ((reg_data[0] & PCA9468_BIT_ADC_IIN7_0) >> 0);

		/*
		 * iin = rawadc*4.89 + (rawadc*4.89 - 900) *
		 * 	 adc_comp_gain/100
		 */
		conv_adc = raw_adc * IIN_STEP + (raw_adc * IIN_STEP -
			   ADC_IIN_OFFSET) * pca9468->adc_comp_gain /
			   100; /* unit - uA */
		/*
		 * If ADC raw value is 0, convert value will be minus value
		 * because of compensation gain, so in this case conv_adc
		 * is 0
		 */
		if (conv_adc < 0)
			conv_adc = 0;
		break;

	case ADCCH_DIETEMP:
		/* ~PCA9468_BIT_CH6_EN, PCA9468_REG_ADC_CFG, udelay(120) us */

		ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_STS_ADC_7,
				       reg_data, 2);
		if (ret < 0) {
			conv_adc = ret;
			goto error;
		}

		raw_adc = ((reg_data[1] & PCA9468_BIT_ADC_DIETEMP9_6) << 6) |
			  ((reg_data[0] & PCA9468_BIT_ADC_DIETEMP5_0) >> 2);

		/* Temp = (935-rawadc)*0.435, unit - C */
		conv_adc = (935 - raw_adc) * DIETEMP_STEP / DIETEMP_DENOM;
		if (conv_adc > DIETEMP_MAX)
			conv_adc = DIETEMP_MAX;
		else if (conv_adc < DIETEMP_MIN)
			conv_adc = DIETEMP_MIN;
		break;

	case ADCCH_NTC:
		/* ~PCA9468_BIT_CH7_EN, PCA9468_REG_ADC_CFG, udelay(120) us */

		ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_STS_ADC_8,
				       reg_data, 2);
		if (ret < 0) {
			conv_adc = ret;
			goto error;
		}

		raw_adc = ((reg_data[1] & PCA9468_BIT_ADC_NTCV9_4) << 4) |
			  ((reg_data[0] & PCA9468_BIT_ADC_NTCV3_0) >> 4);

		/* Temp = (rawadc < 185)? (960-rawadc/4) : (730-rawadc/8) */
		/* unit: 0.1 degree C */
		if (raw_adc < NTC_CURVE_THRESHOLD)
			conv_adc = NTC_CURVE_1_BASE - ((raw_adc * 10) >> NTC_CURVE_1_SHIFT);
		else
			conv_adc = NTC_CURVE_2_BASE - ((raw_adc * 10) >> NTC_CURVE_2_SHIFT);
		break;

	default:
		conv_adc = -EINVAL;
		break;
	}

error:
	/* if disabled a channel, re-enable it in -> PCA9468_REG_ADC_CFG */

	pr_debug("%s: adc_ch=%u, raw_adc=%x convert_val=%d\n", __func__,
		 adc_ch, raw_adc, conv_adc);

	return conv_adc;
}

/* v float voltage (5 mV) resolution */
static int pca9468_set_vfloat(struct pca9468_charger *pca9468,
			      unsigned int v_float)
{
	const int val = PCA9468_V_FLOAT(v_float);
	int ret;

	ret = regmap_write(pca9468->regmap, PCA9468_REG_V_FLOAT, val);

	dev_info(pca9468->dev, "%s: v_float=%u (%d)\n", __func__, v_float, ret);

	return ret;
}

static int pca9468_set_input_current(struct pca9468_charger *pca9468,
				     unsigned int iin)
{
	int ret, val;

	/* round-up and increase one step */
	iin = iin + PD_MSG_TA_CUR_STEP;
	val = PCA9468_IIN_CFG(iin);

	/* Set IIN_CFG to one step higher */
	val = val + 1;
	if (val > 0x32)
		val = 0x32; /* maximum value is 5A */

	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_IIN_CTRL,
				 PCA9468_BIT_IIN_CFG, val);

	dev_info(pca9468->dev, "%s: iin=%d real iin_cfg=%d (%d)\n", __func__,
		 iin, val * PCA9468_IIN_CFG_STEP, ret);

	return ret;
}

/* Returns the enable or disable value. into 1 or 0. */
static int pca9468_get_charging_enabled(struct pca9468_charger *pca9468)
{
	int ret, intval;
	unsigned int val;

	ret = regmap_read(pca9468->regmap, PCA9468_REG_START_CTRL, &val);
	if (ret < 0)
		return ret;

	intval = (val & PCA9468_BIT_STANDBY_EN) ? 0 : 1;

	return intval;
}


/* b/194346461 ramp down IIN */
static int pca9468_wlc_ramp_down_iin(struct pca9468_charger *pca9468,
				     struct power_supply *wlc_psy)
{
	const int ramp_down_step = PCA9468_IIN_CFG_STEP;
	int ret = 0, iin;

	if (!pca9468->wlc_ramp_out_iin)
		return 0;

	iin = pca9468_input_current_limit(pca9468);
	for ( ; iin >= PCA9468_IIN_CFG_MIN; iin -= ramp_down_step) {
		int iin_adc, wlc_iout = -1;

		iin_adc = pca9468_read_adc(pca9468, ADCCH_IIN);
		if (wlc_psy) {
			union power_supply_propval pro_val;

			ret = power_supply_get_property(wlc_psy,
					POWER_SUPPLY_PROP_ONLINE,
					&pro_val);
			if (ret < 0 || pro_val.intval != PPS_PSY_PROG_ONLINE)
				break;

			ret = power_supply_get_property(wlc_psy,
					POWER_SUPPLY_PROP_CURRENT_NOW,
					&pro_val);
			if (ret == 0)
				wlc_iout = pro_val.intval;
		}

		ret = pca9468_set_input_current(pca9468, iin);
		if (ret < 0) {
			pr_err("%s: ramp down iin=%d (%d)\n", __func__,
				iin, ret);
			break;
		}

		pr_debug("%s: iin_adc=%d, wlc_iout-%d ramp down iin=%d\n",
				__func__, iin_adc, wlc_iout, iin);
		msleep(pca9468->wlc_ramp_out_delay);
	}

	return ret;
}

/* b/194346461 ramp down VOUT */
#define WLC_VOUT_CFG_STEP	40000

/* the caller will set to vbatt * 4 */
static int pca9468_wlc_ramp_down_vout(struct pca9468_charger *pca9468,
				      struct power_supply *wlc_psy)
{
	const int ramp_down_step = WLC_VOUT_CFG_STEP;
	union power_supply_propval pro_val;
	int vout = 0, vout_target = pca9468->wlc_ramp_out_vout_target;
	int ret, vbatt;

	while (true) {
		vbatt = pca9468_read_adc(pca9468, ADCCH_VBAT);
		if (vbatt <= 0) {
			pr_err("%s: invalid vbatt %d\n", __func__, vbatt);
			break;
		}

		ret = power_supply_get_property(wlc_psy, POWER_SUPPLY_PROP_VOLTAGE_NOW,
					        &pro_val);
		if (ret < 0) {
			pr_err("%s: invalid vout %d\n", __func__, ret);
			break;
		}

		if (!pca9468->wlc_ramp_out_vout_target)
			vout_target = vbatt * 4;

		if (!vout)
			vout = pro_val.intval;
		if (vout < vout_target) {
			pr_debug("%s: underflow vout=%d, vbatt=%d (target=%d)\n", __func__,
			         vout, vbatt, vout_target);
			return 0;
		}

		pro_val.intval = vout - ramp_down_step;

		pr_debug("%s: vbatt=%d, wlc_vout=%d->%d\n", __func__, vbatt,
			 vout, pro_val.intval);

		ret = power_supply_set_property(wlc_psy, POWER_SUPPLY_PROP_VOLTAGE_NOW,
						&pro_val);
		if (ret < 0) {
			pr_err("%s: cannot set vout %d\n", __func__, ret);
			break;
		}

		msleep(pca9468->wlc_ramp_out_delay);
		vout = pro_val.intval;
	}

	return -EIO;
}

/* call holding mutex_lock(&pca9468->lock); */
static int pca9468_set_charging(struct pca9468_charger *pca9468, bool enable)
{
	const int ntc_protection_en = 0; /* TODO: DT option? */
	int ret, val;

	pr_debug("%s: enable=%d ta_type=%d\n", __func__,  enable, pca9468->ta_type);

	if (enable && pca9468_get_charging_enabled(pca9468) == enable) {
		pr_debug("%s: no op, already enabled\n", __func__);
		return 0;
	}

	/* might needs to disable NTC_PROTECTION_EN in all cases */

	if (enable) {
		/* Improve adc */
		val = 0x5B;
		ret = regmap_write(pca9468->regmap, PCA9468_REG_ADC_ACCESS, val);
		if (ret < 0)
			goto error;
		ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_ADC_IMPROVE,
					 PCA9468_BIT_ADC_IIN_IMP, 0);
		if (ret < 0)
			goto error;

		/* For fixing input current error */
		/* Overwrite 0x00 in 0x41 register */
		val = 0x00;
		ret = regmap_write(pca9468->regmap, 0x41, val);
		if (ret < 0)
			goto error;
		/* Overwrite 0x01 in 0x43 register */
		val = 0x01;
		ret = regmap_write(pca9468->regmap, 0x43, val);
		if (ret < 0)
			goto error;
		/* Overwrite 0x00 in 0x4B register */
		val = 0x00;
		ret = regmap_write(pca9468->regmap, 0x4B, val);
		if (ret < 0)
			goto error;
		/* End for fixing input current error */

	} else {
		/* Disable NTC_PROTECTION_EN */
		ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_TEMP_CTRL,
					 PCA9468_BIT_NTC_PROTECTION_EN, 0);
	}

	if (enable) {
		/* ENABLE PCA9468 */
		ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_START_CTRL,
					 PCA9468_BIT_STANDBY_EN,
					 PCA9468_STANDBY_DONOT);
		if (ret < 0)
			goto error;


		/* Wait 50ms, first to keep the start-up sequence */
		mdelay(50);
		/* Wait 150ms */
		msleep(150);

		/* Improve ADC */
		ret = regmap_update_bits(pca9468->regmap,
					 PCA9468_REG_ADC_IMPROVE,
					 PCA9468_BIT_ADC_IIN_IMP,
					 PCA9468_BIT_ADC_IIN_IMP);
		if (ret  < 0)
			goto error;

		val = 0x00;
		ret = regmap_write(pca9468->regmap, PCA9468_REG_ADC_ACCESS,
				   val);

		/* Restore NTC_PROTECTION_EN */
		ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_TEMP_CTRL,
					 PCA9468_BIT_NTC_PROTECTION_EN,
					 ntc_protection_en);
	} else {

		if (pca9468->ta_type == TA_TYPE_WIRELESS) {
			struct power_supply *wlc_psy;
			int ret;

			wlc_psy = pca9468_get_rx_psy(pca9468);
			if (wlc_psy) {
				ret = pca9468_wlc_ramp_down_iin(pca9468, wlc_psy);
				if (ret < 0)
					dev_err(pca9468->dev, "cannot ramp out iin (%d)\n", ret);

				ret = pca9468_wlc_ramp_down_vout(pca9468, wlc_psy);
				if (ret < 0)
					dev_err(pca9468->dev, "cannot ramp out vout (%d)\n", ret);
			}
		}

		/* turn off the PCA */
		ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_START_CTRL,
					 PCA9468_BIT_STANDBY_EN,
					 PCA9468_STANDBY_FORCED);
		if (ret < 0)
			goto error;

		/* Wait 5ms to keep the shutdown sequence */
		mdelay(5);
	}

error:
	pr_debug("%s: End, ret=%d\n", __func__, ret);
	return ret;
}

static int pca9468_check_state(u8 val[8], struct pca9468_charger *pca9468, int loglevel)
{
	int ret;

	/* Dump register */
	ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_INT1,
			       &val[PCA9468_REG_INT1], 7);
	if (ret < 0)
		return ret;

	logbuffer_prlog(pca9468, loglevel,
			"%s: Error reg[1]=%#x,[2]=%#x,[3]=%#x,[4]=%#x,[5]=%#x,[6]=%#x,[7]=%#x",
			__func__, val[1], val[2], val[3], val[4], val[5], val[6], val[7]);

	return 0;
}

static void pca9468_dump_test_debug(const struct pca9468_charger *pca9468,
				    int loglevel)
{
	u8 test_val[16];
	int ret;

	/* Read test register for debugging */
	ret = regmap_bulk_read(pca9468->regmap, 0x40, test_val, 16);
	if (ret < 0) {
		logbuffer_prlog(pca9468, LOGLEVEL_ERR,
				"%s: cannot read test registers (%d)\n",
				__func__, ret);
	} else {
		logbuffer_prlog(pca9468, loglevel,
				"%s: Error reg[0x40]=%#x,[0x41]=%#x,[0x42]=%#x,[0x43]=%#x,[0x44]=%#x,[0x45]=%#x,[0x46]=%#x,[0x47]=%#x",
				__func__, test_val[0], test_val[1], test_val[2], test_val[3],
				test_val[4], test_val[5], test_val[6], test_val[7]);
		logbuffer_prlog(pca9468, loglevel,
				"%s: Error reg[0x48]=%#x,[0x49]=%#x,[0x4A]=%#x,[0x4B]=%#x,[0x4C]=%#x,[0x4D]=%#x,[0x4E]=%#x,[0x4F]=%#x",
				__func__, test_val[8], test_val[9], test_val[10], test_val[11],
				test_val[12], test_val[13], test_val[14], test_val[15]);
	}
}

static void pca9468_dump_config(const struct pca9468_charger *pca9468,
				int loglevel)
{
	u8 val[10];
	int ret;

	ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_IIN_CTRL,
			       val, sizeof(val));
	if (ret < 0) {
		logbuffer_prlog(pca9468, LOGLEVEL_ERR,
				"%s: cannot read config (%d)\n", __func__, ret);
	} else {
		logbuffer_prlog(pca9468, loglevel,
				"%s: Config reg[0x21]=%#x,[0x22]=%#x,[0x23]=%#x,[0x24]=%#x,[0x25]=%#x,[0x26]=%#x,[0x27]=%#x,[0x28]=%#x,[0x29]=%#x,[0x2A]=%#x",
				__func__, val[0], val[1], val[2], val[3], val[4],
				val[5], val[6], val[7], val[8], val[9]);
	}
}

/* PCA9468 is not active state  - standby or shutdown */
/* Stop charging in timer_work */
/* return 0 when no error is detected */
static int pca9468_check_not_active(struct pca9468_charger *pca9468)
{
	u8 val[8];
	int ret;

	ret = pca9468_check_state(val, pca9468, LOGLEVEL_WARNING);
	if (ret < 0) {
		pr_err("%s: cannot read state\n", __func__);
		return ret;
	}

	pca9468_dump_test_debug(pca9468, LOGLEVEL_ERR);

	/* Check INT1_STS first */
	if ((val[PCA9468_REG_INT1_STS] & PCA9468_BIT_V_OK_STS) != PCA9468_BIT_V_OK_STS) {
		/* VBUS is invalid */
		logbuffer_prlog(pca9468, LOGLEVEL_ERR,
				"%s: VOK is invalid", __func__);

		/* Check STS_A. NOTE: V_OV_TRACKING is with VIN OV */
		if (val[PCA9468_REG_STS_A] & PCA9468_BIT_CFLY_SHORT_STS)
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: Flying Cap is shorted to GND", __func__);
		else if (val[PCA9468_REG_STS_A] & PCA9468_BIT_VOUT_UV_STS)
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: VOUT UV", __func__); /* VOUT < VOUT_OK */
		else if (val[PCA9468_REG_STS_A] & PCA9468_BIT_VBAT_OV_STS)
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: VBAT OV", __func__); /* VBAT > VBAT_OV */
		else if (val[PCA9468_REG_STS_A] & PCA9468_BIT_VIN_OV_STS)
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: VIN OV", __func__); /* VIN > V_OV_FIXED */
		else if (val[PCA9468_REG_STS_A] & PCA9468_BIT_VIN_UV_STS)
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: VIN UV", __func__); /* VIN < V_UVTH */
		else
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: Invalid VIN or VOUT", __func__);

		return  -EINVAL;
	}

	if (val[PCA9468_REG_INT1_STS] & PCA9468_BIT_NTC_TEMP_STS) {
		int ntc_adc, ntc_th; /* NTC protection */
		u8 reg_data[2]; /* NTC threshold */

		ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_NTC_TH_1,
				       reg_data, sizeof(reg_data));
		if (ret < 0)
			return -EIO;

		ntc_th = ((reg_data[1] & PCA9468_BIT_NTC_THRESHOLD9_8) << 8) |
			 reg_data[0];	/* uV unit */

		/* Read NTC ADC */
		ntc_adc = pca9468_read_adc(pca9468, ADCCH_NTC);	/* uV unit */
		logbuffer_prlog(pca9468, LOGLEVEL_ERR,
				"%s: NTC Protection, NTC_TH=%d(uV), NTC_ADC=%d(uV)",
				__func__, ntc_th, ntc_adc);

		return -EINVAL;
	}

	if (val[PCA9468_REG_INT1_STS] & PCA9468_BIT_CTRL_LIMIT_STS) {
		/* OCP event happens */

		if (val[PCA9468_REG_STS_B] & PCA9468_BIT_OCP_FAST_STS)
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: IIN is over OCP_FAST", __func__);
		else if (val[PCA9468_REG_STS_B] & PCA9468_BIT_OCP_AVG_STS)
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: IIN is over OCP_AVG", __func__);
		else
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: No Loop active", __func__);

		return -EINVAL;
	}

	if (val[PCA9468_REG_INT1_STS] & PCA9468_BIT_TEMP_REG_STS) {
		/* Over temperature protection */
		logbuffer_prlog(pca9468, LOGLEVEL_ERR,
				"%s: Device is in temperature regulation", __func__);
		return -EINVAL;
	}

	if (val[PCA9468_REG_INT1_STS] & PCA9468_BIT_TIMER_STS) {
		const u8 sts_b = val[PCA9468_REG_STS_B];

		if (sts_b & PCA9468_BIT_CHARGE_TIMER_STS)
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: Charger timer is expired", __func__);
		else if (sts_b & PCA9468_BIT_WATCHDOG_TIMER_STS)
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
				"%s: Watchdog timer is expired", __func__);
		else
			logbuffer_prlog(pca9468, LOGLEVEL_ERR,
					"%s: Timer INT, but no timer STS", __func__);

		return -EINVAL;
	}

	if (val[PCA9468_REG_STS_A] & PCA9468_BIT_CFLY_SHORT_STS) {
		logbuffer_prlog(pca9468, LOGLEVEL_ERR,
				"%s: Flying Cap is shorted to GND", __func__);
		return -EINVAL;
	}

	return 0;
}

/* Keep the current charging state, check STS_B again */
/* return 0 if VIN is still present, -EAGAIN if needs to retry, -EINVAL oth */
static int pca9468_check_standby(struct pca9468_charger *pca9468)
{
	unsigned int reg_val;
	int ret;
	u8 val[8];

	/* re-read the state register */
	ret = regmap_read(pca9468->regmap, PCA9468_REG_STS_B, &reg_val);
	if (ret < 0)
		return -EIO;

	pr_debug("%s: RCP check, STS_B=%#x\n",	__func__, reg_val);

	/* RCP condition, but VIN is valid and the PCA is active */
	if (reg_val & PCA9468_BIT_ACTIVE_STATE_STS) {
		const int charging_state = pca9468->charging_state;

		/*
		 * Try again when called from pca9468_check_active_state().
		 * If VIN is increased, input current will increase over
		 * IIN_LOW level.
		 */
		logbuffer_prlog(pca9468, charging_state == DC_STATE_CHECK_ACTIVE ?
				LOGLEVEL_WARNING : LOGLEVEL_ERR,
				"%s: RCP triggered but VIN is valid, state=%d",
				__func__, charging_state);

		pca9468->chg_data.rcp_count++;
		return -EAGAIN;
	}

	/* re-read and dump state, debug registers */
	pca9468_check_state(val, pca9468, LOGLEVEL_INFO);
	ret = regmap_bulk_read(pca9468->regmap, 0x48, val, 3);
	logbuffer_prlog(pca9468, LOGLEVEL_ERR,
			"%s: Error reg[0x48]=%#x,[0x49]=%#x,[0x4a]=%#x",
			__func__, val[0], val[1], val[2]);
	pca9468_dump_config(pca9468, LOGLEVEL_INFO);

	/* Not in RCP state, retry only when DC is starting */
	if (reg_val & PCA9468_BIT_STANDBY_STATE_STS) {
		logbuffer_prlog(pca9468, LOGLEVEL_WARNING, "%s: device in standby", __func__);
		pca9468->chg_data.stby_count++;
		ret = -EAGAIN;
	}  else {
		logbuffer_prlog(pca9468, LOGLEVEL_ERR, "%s: device in shutdown", __func__);
		p9468_chg_stats_update_flags(&pca9468->chg_data, P9468_CHGS_F_SHDN);
		ret = -EINVAL;
	}

	return ret;
}

/*
 * Check Active status, 0 is active (or in RCP), <0 indicates a problem.
 * The function is called from different contexts/functions, errors are fatal
 * (i.e. stop charging) from all contexts except when this is called from
 * pca9468_check_active_state().
 *
 * Other contexts:
 * . pca9468_charge_adjust_ccmode
 * . pca9468_charge_ccmode
 * . pca9468_charge_start_cvmode
 * . pca9468_charge_cvmode
 *
 * call holding mutex_lock(&pca9468->lock)
 */
static int pca9468_check_error(struct pca9468_charger *pca9468)
{
	unsigned int reg_val;
	int ret;

	ret = regmap_read(pca9468->regmap, PCA9468_REG_STS_B, &reg_val);
	if (ret < 0)
		goto error;

	/* PCA9468 is active state */
	if (reg_val & PCA9468_BIT_ACTIVE_STATE_STS) {
		int vbatt;

		/* PCA9468 is charging */

		/* Check whether the battery voltage is over the minimum */
		vbatt = pca9468_read_adc(pca9468, ADCCH_VBAT);
		if (vbatt > PCA9468_DC_VBAT_MIN) {
			/* Normal charging battery level */
			/* Check temperature regulation loop */
			/* Read INT1_STS register */
			ret = regmap_read(pca9468->regmap, PCA9468_REG_INT1_STS,
					  &reg_val);
			if (ret < 0) {
				pr_err("%s: cannot read status (%d)\n", __func__, ret);
			} else if (reg_val & PCA9468_BIT_TEMP_REG_STS) {
				/* Over temperature protection */
				pr_err("%s: Device is in temperature regulation\n",
					__func__);
				ret = -EINVAL;
			}
		} else {
			/* Abnormal battery level */
			pr_err("%s: Error abnormal battery voltage=%d\n",
				__func__, vbatt);
			ret = -EINVAL;
		}

		pr_debug("%s: Active Status ok=%d (ret=%d)\n", __func__,
			 ret == 0, ret);
		return ret;
	}

	/* not in error but in standby or shutdown */

	ret = pca9468_check_not_active(pca9468);
	if (ret < 0) {
		/* There was an error, done... */
	} else if ((reg_val & PCA9468_BIT_STANDBY_STATE_STS) == 0) {
		/* PCA9468 is in shutdown state */
		pr_err("%s: PCA9468 is in shutdown\n", __func__);
		ret = -EINVAL;
	} else if (pca9468->charging_state == DC_STATE_NO_CHARGING) {
		/*
		 * Sometimes battery driver might call set_property function
		 * to stop charging during msleep. At this case, charging
		 * state would change DC_STATE_NO_CHARGING. PCA9468 should
		 * stop checking RCP condition and exit timer_work
		 */
		pr_err("%s: other driver forced stop\n", __func__);
		ret = -EINVAL;
	} else {

		/* Check the RCP condition, T_REVI_DET is 300ms */
		msleep(200);

		/*
		 * return 0 if VIN is still present, -EAGAIN if needs to retry,
		 * -EINVAL on error.
		 */
		ret = pca9468_check_standby(pca9468);
	}

error:
	pr_debug("%s: Not Active Status=%d\n", __func__, ret);
	return ret;
}

static int pca9468_get_iin(struct pca9468_charger *pca9468, int *iin)
{
	const int offset = iin_fsw_cfg[pca9468->pdata->fsw_cfg];
	int temp;

	temp = pca9468_read_adc(pca9468, ADCCH_IIN);
	if (temp < 0)
		return temp;

	if (temp < offset)
		temp = offset;

	*iin = (temp - offset) * 2;
	return 0;
}

/* only needed for irdrop compensation ane maybe not even that... */
static int pca9468_get_batt_info(struct pca9468_charger *pca9468, int info_type, int *info)
{
	union power_supply_propval val;
	enum power_supply_property psp;
	int ret;

	if (!pca9468->batt_psy)
		pca9468->batt_psy = power_supply_get_by_name("battery");
	if (!pca9468->batt_psy)
		return -EINVAL;

	if (info_type == BATT_CURRENT)
		psp = POWER_SUPPLY_PROP_CURRENT_NOW;
	else
		psp = POWER_SUPPLY_PROP_VOLTAGE_NOW;

	ret = power_supply_get_property(pca9468->batt_psy, psp, &val);
	if (ret == 0)
		*info = val.intval;

	return ret;
}

/* only needed for irdrop compensation ane maybe not even that... */
static int pca9468_get_ibatt(struct pca9468_charger *pca9468, int *info)
{
	return pca9468_get_batt_info(pca9468, BATT_CURRENT, info);
}

static void pca9468_prlog_state(struct pca9468_charger *pca9468, const char *fn)
{
	int rc, ibat, icn = -EINVAL, iin = -EINVAL;
	bool ovc_flag;

	rc = pca9468_get_ibatt(pca9468, &ibat);
	if (rc == 0)
		rc = pca9468_get_iin(pca9468, &icn);
	if (rc == 0)
		iin = pca9468_read_adc(pca9468, ADCCH_IIN);
	ovc_flag = ibat > pca9468->cc_max;
	if (ovc_flag)
		p9468_chg_stats_inc_ovcf(&pca9468->chg_data, ibat, pca9468->cc_max);;

	logbuffer_prlog(pca9468, ovc_flag ? LOGLEVEL_WARNING : LOGLEVEL_DEBUG,
			"%s: iin=%d, iin_cc=%d, icn=%d ibat=%d, cc_max=%d rc=%d",
			fn, iin, pca9468->iin_cc, icn, ibat, pca9468->cc_max, rc);
}

static int pca9468_read_status(struct pca9468_charger *pca9468)
{
	unsigned int reg_val;
	int ret;

	/* Read STS_A */
	ret = regmap_read(pca9468->regmap, PCA9468_REG_STS_A, &reg_val);
	if (ret < 0)
		return ret;

	if (reg_val & PCA9468_BIT_VIN_UV_STS) {
		ret = STS_MODE_VIN_UVLO;
	} else if (reg_val & PCA9468_BIT_IIN_LOOP_STS) {
		ret = STS_MODE_IIN_LOOP;
	} else if (reg_val & PCA9468_BIT_CHG_LOOP_STS) {
		ret = STS_MODE_CHG_LOOP; /* never */
	} else if (reg_val & PCA9468_BIT_VFLT_LOOP_STS) {
		ret = STS_MODE_VFLT_LOOP;
	} else {
		ret = STS_MODE_LOOP_INACTIVE; /* lower IIN or TA to enter CC? */
	}

	return ret;
}

/*
 * TODO: add formula and/or use device tree entries to configure. Can use
 * delta = PCA9468_COMP_VFLOAT_MAX to reduce the limit as float voltage
 * increases.
 * NOTE: how does this change with temperature, battery age?
 */
static int pca9468_irdrop_limit(struct pca9468_charger *pca9468, int fv_uv)
{
	int delta = pca9468->pdata->irdrop_limits[1];

	if (fv_uv < 4300000)
		delta = pca9468->pdata->irdrop_limits[0];
	if (fv_uv >= PCA9468_COMP_VFLOAT_MAX)
		delta = pca9468->pdata->irdrop_limits[2];

	return delta;
}

/* use max limit,  */
static int pca9468_apply_irdrop(struct pca9468_charger *pca9468, int fv_uv)
{
	const int delta_limit = pca9468_irdrop_limit(pca9468, fv_uv);
	int ret, vbat, pca_vbat = 0, delta = 0;
	const bool adaptive = false;

	/* use classic irdrop */
	if (pca9468->irdrop_comp_ok)
		goto error_done;

	ret = pca9468_get_batt_info(pca9468, BATT_VOLTAGE, &vbat);
	if (ret < 0)
		goto error_done;

	pca_vbat = pca9468_read_adc(pca9468, ADCCH_VBAT);
	if (pca_vbat < 0 || pca_vbat < vbat)
		goto error_done;

	if (adaptive) {
		delta = pca_vbat - vbat;
		if (delta > delta_limit)
			delta = delta_limit;
	} else {
		delta = delta_limit;
	}

	if (fv_uv + delta > PCA9468_COMP_VFLOAT_MAX)
		delta = PCA9468_COMP_VFLOAT_MAX - fv_uv;

error_done:
	pr_debug("%s: fv_uv=%d->%d pca_vbat=%d, vbat=%d delta_v=%d\n",
		 __func__, fv_uv, fv_uv + delta, pca_vbat,
		 ret < 0 ? ret : vbat, delta);

	if (fv_uv + delta < pca_vbat) {
		pr_err("%s: fv_uv=%d, comp_fv_uv=%d is lower than VBAT=%d\n",
		       __func__, fv_uv, fv_uv + delta, pca_vbat);
		return -EINVAL;
	}

	return fv_uv + delta;
}

static int pca9468_const_charge_voltage(struct pca9468_charger *pca9468);

/* irdrop compensation for the pca9468 V_FLOAT, will only raise it */
static int pca9468_comp_irdrop(struct pca9468_charger *pca9468)
{
	int ret = 0, v_float, fv_uv;

	v_float = pca9468_const_charge_voltage(pca9468);
	if (v_float < 0)
		return -EIO;

	fv_uv = pca9468_apply_irdrop(pca9468, pca9468->fv_uv);
	if (fv_uv < 0)
		return -EIO;

	/* do not back down */
	if (fv_uv > v_float) {
		ret = pca9468_set_vfloat(pca9468, fv_uv);
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"%s: v_float=%u->%u (%d)", __func__,
				v_float, fv_uv, ret);
	}

	return ret;
}

static int pca9468_check_status(struct pca9468_charger *pca9468)
{
	int icn = -EINVAL, ibat = -EINVAL, vbat = -EINVAL;
	int rc, status;

	status = pca9468_read_status(pca9468);
	if (status < 0)
		goto error;

	rc = pca9468_get_iin(pca9468, &icn);
	if (rc == 0)
		rc = pca9468_get_batt_info(pca9468, BATT_CURRENT, &ibat);
	if (rc == 0)
		rc = pca9468_get_batt_info(pca9468, BATT_VOLTAGE, &vbat);

error:
	pr_debug("%s: status=%d icn:%d ibat:%d delta_c=%d, vbat:%d, fv:%d, cc_max:%d\n",
		 __func__, status, icn, ibat, icn - ibat, vbat,
		 pca9468->fv_uv, pca9468->cc_max);

	return status;
}

/* hold mutex_lock(&pca9468->lock); */
static int pca9468_recover_ta(struct pca9468_charger *pca9468)
{
	int ret;

	if (pca9468->ta_type == TA_TYPE_WIRELESS) {
		pca9468->ta_vol = 0; /* set to a value to change rx vol */
		ret = pca9468_send_rx_voltage(pca9468, MSG_REQUEST_FIXED_PDO);
	} else {
		/* TODO: recover TA to value before handoff, or use DT */
		pca9468->ta_vol = 9000000;
		pca9468->ta_cur = 2200000;
		pca9468->ta_objpos = 1; /* PDO1 - fixed 5V */
		ret = pca9468_send_pd_message(pca9468, MSG_REQUEST_FIXED_PDO);
	}

	/* will not be able to recover if TA is offline */
	if (ret < 0)
		pr_debug("%s: cannot recover TA (%d)\n", __func__, ret);

	return 0;
}

/* Stop Charging */
static int pca9468_stop_charging(struct pca9468_charger *pca9468)
{
	int ret = 0;

	/* mark the end with \n in logbuffer */
	logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
			"%s: pca9468->charging_state=%d ret=%d\n",
			__func__, pca9468->charging_state, ret);

	mutex_lock(&pca9468->lock);

	/* Check the current state */
	if (pca9468->charging_state == DC_STATE_NO_CHARGING)
		goto done;

	/* Stop Direct charging  */
	cancel_delayed_work(&pca9468->timer_work);
	cancel_delayed_work(&pca9468->pps_work);
	pca9468->timer_id = TIMER_ID_NONE;
	pca9468->timer_period = 0;

	/* Clear parameter */
	pca9468->charging_state = DC_STATE_NO_CHARGING;
	pca9468->ret_state = DC_STATE_NO_CHARGING;
	pca9468->prev_iin = 0;
	pca9468->prev_inc = INC_NONE;
	pca9468->chg_mode = CHG_NO_DC_MODE;

	/* restore to config */
	pca9468->pdata->iin_cfg = pca9468->pdata->iin_cfg_max;
	pca9468->pdata->v_float = pca9468->pdata->v_float_dt;

	/*
	 * Clear charging configuration
	 * TODO: use defaults when these are negative or zero at startup
	 * NOTE: cc_max is twice of IIN + headroom
	 */
	pca9468->cc_max = -1;
	pca9468->fv_uv = -1;

	/* Clear requests for new Vfloat and new IIN */
	pca9468->new_vfloat = 0;
	pca9468->new_iin = 0;

	/* used to start DC and during errors */
	pca9468->retry_cnt = 0;

	/* close stats */
	p9468_chg_stats_done(&pca9468->chg_data, pca9468);
	p9468_chg_stats_dump(pca9468);

	/* TODO: something here to prep TA for the switch */

	ret = pca9468_set_charging(pca9468, false);
	if (ret < 0) {
		pr_err("%s: Error-set_charging(main)\n", __func__);
		goto error;
	}

	/* stop charging and recover TA voltage */
	if (pca9468->mains_online == true)
		pca9468_recover_ta(pca9468);

	power_supply_changed(pca9468->mains);

done:
error:
	mutex_unlock(&pca9468->lock);
	__pm_relax(pca9468->monitor_wake_lock);
	pr_debug("%s: END, ret=%d\n", __func__, ret);
	return ret;
}

#define FCC_TOLERANCE_RATIO		99
#define FCC_POWER_INCREASE_THRESHOLD	99

/*
 * Compensate TA current for the target input current called from
 * pca9468_charge_ccmode() when loop becomes not active.
 *
 * pca9468_charge_ccmode() ->
 * 	-> pca9468_set_rx_voltage_comp()
 * 	-> pca9468_set_ta_voltage_comp()
 * 	-> pca9468_set_ta_current_comp2()
 *
 * NOTE: call holding mutex_lock(&pca9468->lock);
 */
static int pca9468_set_ta_current_comp(struct pca9468_charger *pca9468)
{
	const int iin_high = pca9468->iin_cc + pca9468->pdata->iin_cc_comp_offset;
	const int iin_low = pca9468->iin_cc - pca9468->pdata->iin_cc_comp_offset;
	int rc, ibat, icn = -EINVAL, iin = -EINVAL;
	bool ovc_flag;

	/* IIN = IBAT+SYSLOAD */
	rc = pca9468_get_ibatt(pca9468, &ibat);
	if (rc == 0)
		rc = pca9468_get_iin(pca9468, &icn);
	if (rc == 0)
		iin = pca9468_read_adc(pca9468, ADCCH_IIN);

	ovc_flag = ibat > pca9468->cc_max;
	if (ovc_flag)
		p9468_chg_stats_inc_ovcf(&pca9468->chg_data, ibat, pca9468->cc_max);

	logbuffer_prlog(pca9468, ovc_flag ? LOGLEVEL_WARNING : LOGLEVEL_DEBUG,
			"%s: iin=%d, iin_cc=[%d,%d,%d], icn=%d ibat=%d, cc_max=%d rc=%d prev_iin=%d",
			__func__, iin, iin_low, pca9468->iin_cc, iin_high,
			icn, ibat, pca9468->cc_max, rc,
			pca9468->prev_iin);
	if (iin < 0)
		return iin;

	/* Compare IIN ADC with target input current */
	if (iin > iin_high) {

		/* TA current is higher than the target input current */
		if (pca9468->ta_cur > pca9468->iin_cc) {
			/* TA current is over than IIN_CC */
			/* Decrease TA current (50mA) */
			pca9468->ta_cur = pca9468->ta_cur - PD_MSG_TA_CUR_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont1: ta_cur=%u",
					pca9468->ta_cur);

		/* TA current is already less than IIN_CC */
		/* Compara IIN_ADC with the previous IIN_ADC */
		} else if (iin < (pca9468->prev_iin - PCA9468_IIN_ADC_OFFSET)) {
			/* Assume that TA operation mode is CV mode */
			/* Decrease TA voltage (20mV) */
			pca9468->ta_vol = pca9468->ta_vol - PD_MSG_TA_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont2-1: ta_vol=%u",
					pca9468->ta_vol);
		} else {
			/* Assume TA operation mode is CL mode */
			/* Decrease TA current (50mA) */
			pca9468->ta_cur = pca9468->ta_cur - PD_MSG_TA_CUR_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont2-2: ta_cur=%u",
					pca9468->ta_cur);
		}

		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;

	} else if (iin < iin_low) {

		/* compare IIN ADC with previous IIN ADC + 20mA */
		if (iin > (pca9468->prev_iin + PCA9468_IIN_ADC_OFFSET)) {
			/*
			 * TA voltage is not enough to supply the operating
			 * current of RDO: increase TA voltage
			 */

			/* Compare TA max voltage */
			if (pca9468->ta_vol == pca9468->ta_max_vol) {
				/* TA voltage is already the maximum voltage */
				/* Compare TA max current */
				if (pca9468->ta_cur == pca9468->ta_max_cur) {
					/* TA voltage and current are at max */
					logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
							"End1: ta_vol=%u, ta_cur=%u",
							pca9468->ta_vol, pca9468->ta_cur);

					/* Set timer */
					pca9468->timer_id = TIMER_CHECK_CCMODE;
					pca9468->timer_period = PCA9468_CCMODE_CHECK1_T;
				} else {
					/* Increase TA current (50mA) */
					pca9468->ta_cur = pca9468->ta_cur + PD_MSG_TA_CUR_STEP;

					logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
							"Cont3: ta_cur=%u",
							pca9468->ta_cur);

					/* Send PD Message */
					pca9468->timer_id = TIMER_PDMSG_SEND;
					pca9468->timer_period = 0;

					/* Set TA increment flag */
					pca9468->prev_inc = INC_TA_CUR;
				}
			} else {
				/* Increase TA voltage (20mV) */
				pca9468->ta_vol = pca9468->ta_vol + PD_MSG_TA_VOL_STEP;
				logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
						"Cont4: ta_vol=%u", pca9468->ta_vol);

				/* Send PD Message */
				pca9468->timer_id = TIMER_PDMSG_SEND;
				pca9468->timer_period = 0;

				/* Set TA increment flag */
				pca9468->prev_inc = INC_TA_VOL;
			}

		/* TA current is lower than the target input current */
		/* Check the previous TA increment */
		} else if (pca9468->prev_inc == INC_TA_VOL) {
			/*
			 * The previous increment is TA voltage, but
			 * input current does not increase.
			 */

			/* Try to increase TA current */
			/* Compare TA max current */
			if (pca9468->ta_cur == pca9468->ta_max_cur) {

				/* TA current is already the maximum current */
				/* Compare TA max voltage */
				if (pca9468->ta_vol == pca9468->ta_max_vol) {
					/*
					 * TA voltage and current are already
					 * the maximum values
					 */
					logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
							"End2: ta_vol=%u, ta_cur=%u",
							pca9468->ta_vol, pca9468->ta_cur);

					pca9468->timer_id = TIMER_CHECK_CCMODE;
					pca9468->timer_period = PCA9468_CCMODE_CHECK1_T;
				} else {
					/* Increase TA voltage (20mV) */
					pca9468->ta_vol = pca9468->ta_vol + PD_MSG_TA_VOL_STEP;
					logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
							"Cont5: ta_vol=%u",
							pca9468->ta_vol);

					/* Send PD Message */
					pca9468->timer_id = TIMER_PDMSG_SEND;
					pca9468->timer_period = 0;

					/* Set TA increment flag */
					pca9468->prev_inc = INC_TA_VOL;
				}
			} else {
				const unsigned int ta_cur = pca9468->ta_cur +
							    PD_MSG_TA_CUR_STEP;

				/* Increase TA current (50mA) */
				logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
						"Cont6: ta_cur=%u->%u",
						pca9468->ta_cur, ta_cur);

				pca9468->ta_cur = pca9468->ta_cur + PD_MSG_TA_CUR_STEP;
				pca9468->timer_id = TIMER_PDMSG_SEND;
				pca9468->timer_period = 0;

				pca9468->prev_inc = INC_TA_CUR;
			}

		/*
		 * The previous increment was TA current, but input current
		 * did not increase. Try to increase TA voltage.
		 */
		} else if (pca9468->ta_vol == pca9468->ta_max_vol) {
			/* TA voltage is already the maximum voltage */

			/* Compare TA maximum current */
			if (pca9468->ta_cur == pca9468->ta_max_cur) {
				/*
				* TA voltage and current are already at the
				 * maximum values
				 */
				logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
						"End3: ta_vol=%u, ta_cur=%u",
						 pca9468->ta_vol, pca9468->ta_cur);

				pca9468->timer_id = TIMER_CHECK_CCMODE;
				pca9468->timer_period = PCA9468_CCMODE_CHECK1_T;
			} else {
				/* Increase TA current (50mA) */
				pca9468->ta_cur = pca9468->ta_cur + PD_MSG_TA_CUR_STEP;
				logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
						"Cont7: ta_cur=%u", pca9468->ta_cur);

				/* Send PD Message */
				pca9468->timer_id = TIMER_PDMSG_SEND;
				pca9468->timer_period = 0;

				/* Set TA increment flag */
				pca9468->prev_inc = INC_TA_CUR;
			}
		} else {
			/* Increase TA voltage (20mV) */
			pca9468->ta_vol = pca9468->ta_vol + PD_MSG_TA_VOL_STEP;

			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"Comp. Cont8: ta_vol=%u->%u",
					pca9468->ta_vol, pca9468->ta_vol);

			/* Send PD Message */
			pca9468->timer_id = TIMER_PDMSG_SEND;
			pca9468->timer_period = 0;

			/* Set TA increment flag */
			pca9468->prev_inc = INC_TA_VOL;
		}

	} else {
		/* IIN ADC is in valid range */
		/* IIN_CC - 50mA < IIN ADC < IIN_CC + 50mA  */
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"Comp. End4(valid): ta_vol=%u, ta_cur=%u",
				pca9468->ta_vol, pca9468->ta_cur);
		/* Set timer */
		pca9468->timer_id = TIMER_CHECK_CCMODE;
		pca9468->timer_period = PCA9468_CCMODE_CHECK1_T;

		/* b/186969924: reset increment state on valid */
		pca9468->prev_inc = INC_NONE;
	}

	/* Save previous iin adc */
	pca9468->prev_iin = iin;
	return 0;
}

/*
 * max iin for 2:1 mode given cc_max and iin_cfg.
 * TODO: maybe use pdata->iin_cfg if cc_max is zero or negative.
 */
static int pca9468_get_iin_max(const struct pca9468_charger *pca9468, int cc_max)
{
	const int cc_limit = pca9468->pdata->iin_max_offset + cc_max / 2;
	int iin_max;

	iin_max = min(pca9468->pdata->iin_cfg_max, (unsigned int)cc_limit);

	pr_debug("%s: iin_max=%d iin_cfg=%u iin_cfg_max=%d cc_max=%d cc_limit=%d\n",
		 __func__, iin_max, pca9468->pdata->iin_cfg,
		 pca9468->pdata->iin_cfg_max, cc_max, cc_limit);

	return iin_max;
}

/* Compensate TA current for constant power mode */
/* hold mutex_lock(&pca9468->lock), schedule on return 0 */
static int pca9468_set_ta_current_comp2(struct pca9468_charger *pca9468)
{
	int rc, ibat, icn = -EINVAL, iin = -EINVAL;
	bool ovc_flag;

	/* IIN = IBAT+SYSLOAD */
	rc = pca9468_get_ibatt(pca9468, &ibat);
	if (rc == 0)
		rc = pca9468_get_iin(pca9468, &icn);
	if (rc == 0)
		iin = pca9468_read_adc(pca9468, ADCCH_IIN);

	ovc_flag = ibat > pca9468->cc_max;
	if (ovc_flag)
		p9468_chg_stats_inc_ovcf(&pca9468->chg_data, ibat, pca9468->cc_max);;

	logbuffer_prlog(pca9468, ovc_flag ? LOGLEVEL_WARNING : LOGLEVEL_DEBUG,
			"%s: iin=%d, iin_cc=[%d,%d,%d], iin_cfg=%d icn=%d ibat=%d, cc_max=%d rc=%d",
			__func__, iin,
			pca9468->iin_cc - PCA9468_IIN_CC_COMP_OFFSET_CP,
			pca9468->iin_cc,
			pca9468->iin_cc + PCA9468_IIN_CC_COMP_OFFSET_CP,
			pca9468->pdata->iin_cfg,
			icn, ibat, pca9468->cc_max, rc);
	if (iin < 0)
		return iin;

	/* Compare IIN ADC with target input current */
	if (iin > (pca9468->pdata->iin_cfg + pca9468->pdata->iin_cc_comp_offset)) {
		/* TA current is higher than the target input current limit */
		pca9468->ta_cur = pca9468->ta_cur - PD_MSG_TA_CUR_STEP;

		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
	} else if (iin < (pca9468->iin_cc - PCA9468_IIN_CC_COMP_OFFSET_CP)) {

		/* TA current is lower than the target input current */
		/* IIN_ADC < IIN_CC -20mA */
		if (pca9468->ta_vol == pca9468->ta_max_vol) {
			const int iin_cc_lb = pca9468->iin_cc -
				      pca9468->pdata->iin_cc_comp_offset;

			/* Check IIN_ADC < IIN_CC - 50mA */
			if (iin < iin_cc_lb) {
				unsigned int iin_apdo;
				unsigned int val;

				/* Set new IIN_CC to IIN_CC - 50mA */
				pca9468->iin_cc = pca9468->iin_cc -
					  pca9468->pdata->iin_cc_comp_offset;

				/* Set new TA_MAX_VOL to TA_MAX_PWR/IIN_CC */
				/* Adjust new IIN_CC with APDO resolution */
				iin_apdo = pca9468->iin_cc / PD_MSG_TA_CUR_STEP;
				iin_apdo = iin_apdo * PD_MSG_TA_CUR_STEP;
				/* in mV */
				val = pca9468->ta_max_pwr / (iin_apdo / pca9468->chg_mode / 1000);
				/* Adjust values with APDO resolution(20mV) */
				val = val * 1000 / PD_MSG_TA_VOL_STEP;
				val = val * PD_MSG_TA_VOL_STEP; /* uV */

				/* Set new TA_MAX_VOL */
				pca9468->ta_max_vol = min(val, (unsigned)PCA9468_TA_MAX_VOL *
							  pca9468->chg_mode);

				/* Increase TA voltage(40mV) */
				pca9468->ta_vol = pca9468->ta_vol + PD_MSG_TA_VOL_STEP * 2;

				logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
						"Cont1: ta_vol=%u",
						pca9468->ta_vol);

				/* Send PD Message */
				pca9468->timer_id = TIMER_PDMSG_SEND;
				pca9468->timer_period = 0;
			} else {
				/* Wait for next current step compensation */
				/* IIN_CC - 50mA < IIN ADC < IIN_CC - 20mA */
				logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
						"Comp.(wait): ta_vol=%u",
						pca9468->ta_vol);

				/* Set timer */
				pca9468->timer_id = TIMER_CHECK_CCMODE;
				pca9468->timer_period = PCA9468_CCMODE_CHECK2_T;
			}
		} else {
			/* Increase TA voltage(40mV) */
			pca9468->ta_vol = pca9468->ta_vol + PD_MSG_TA_VOL_STEP * 2;
			if (pca9468->ta_vol > pca9468->ta_max_vol)
				pca9468->ta_vol = pca9468->ta_max_vol;

			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont2: ta_vol=%u",
					pca9468->ta_vol);

			/* Send PD Message */
			pca9468->timer_id = TIMER_PDMSG_SEND;
			pca9468->timer_period = 0;
		}
	} else {
		/* IIN ADC is in valid range */
		/* IIN_CC - 50mA < IIN ADC < IIN_CFG + 50mA */
		pr_debug("End(valid): ta_vol=%u\n", pca9468->ta_vol);

		pca9468->timer_id = TIMER_CHECK_CCMODE;
		pca9468->timer_period = PCA9468_CCMODE_CHECK2_T;

		/* b/186969924: reset increment state on valid */
		pca9468->prev_inc = INC_NONE;
	}

	/* Save previous iin adc */
	pca9468->prev_iin = iin;
	return 0;
}

/* Compensate TA voltage for the target input current */
/* hold mutex_lock(&pca9468->lock), schedule on return 0 */
static int pca9468_set_ta_voltage_comp(struct pca9468_charger *pca9468)
{
	const int iin_high = pca9468->iin_cc + pca9468->pdata->iin_cc_comp_offset;
	const int iin_low = pca9468->iin_cc - pca9468->pdata->iin_cc_comp_offset;
	const ibat_limit = (pca9468->cc_max * FCC_POWER_INCREASE_THRESHOLD) / 100;
	int rc, ibat, icn = -EINVAL, iin = -EINVAL;
	bool ovc_flag;

	pr_debug("%s: ======START=======\n", __func__);
	pr_debug("%s: = charging_state=%u == \n", __func__,
		 pca9468->charging_state);

	/* IIN = IBAT+SYSLOAD */
	rc = pca9468_get_ibatt(pca9468, &ibat);
	if (rc == 0)
		rc = pca9468_get_iin(pca9468, &icn);
	if (rc == 0)
		iin = pca9468_read_adc(pca9468, ADCCH_IIN);

	ovc_flag = ibat > pca9468->cc_max;
	if (ovc_flag)
		p9468_chg_stats_inc_ovcf(&pca9468->chg_data, ibat, pca9468->cc_max);;

	logbuffer_prlog(pca9468, ovc_flag ? LOGLEVEL_WARNING : LOGLEVEL_DEBUG,
			"%s: iin=%d, iin_cc=[%d,%d,%d], icn=%d ibat=%d, cc_max=%d rc=%d",
			__func__, iin, iin_low, pca9468->iin_cc, iin_high,
			icn, ibat, pca9468->cc_max, rc);

	if (iin < 0)
		return iin;

	/* Compare IIN ADC with target input current */
	if (iin > iin_high) {
		/* TA current is higher than the target input current */
		/* Decrease TA voltage (20mV) */
		pca9468->ta_vol = pca9468->ta_vol - PD_MSG_TA_VOL_STEP;
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont1: ta_vol=%u",
				pca9468->ta_vol);

		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;

	} else if (iin < pca9468->iin_cc - pca9468->pdata->iin_cc_comp_offset) {

		/* TA current is lower than the target input current */
		/* Compare TA max voltage */
		if (pca9468->ta_vol == pca9468->ta_max_vol) {
			/* TA is already at maximum voltage */
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,"End1(max TA vol): ta_vol=%u",
					pca9468->ta_vol);

			/* Set timer */
			/* Check the current charging state */
			if (pca9468->charging_state == DC_STATE_CC_MODE) {
				/* CC mode */
				pca9468->timer_id = TIMER_CHECK_CCMODE;
				pca9468->timer_period = PCA9468_CCMODE_CHECK1_T;
			} else {
				/* CV mode */
				pca9468->timer_id = TIMER_CHECK_CVMODE;
				pca9468->timer_period = PCA9468_CVMODE_CHECK_T;
			}
		} else {
			const unsigned ta_vol = pca9468->ta_vol;

			/* Increase TA voltage (20mV) */
			pca9468->ta_vol = pca9468->ta_vol + PD_MSG_TA_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont2: ta_vol:%u->%u",
					ta_vol, pca9468->ta_vol);

			/* Send PD Message */
			pca9468->timer_id = TIMER_PDMSG_SEND;
			pca9468->timer_period = 0;
		}
	} else {
		/* IIN ADC is in valid range */
		/* IIN_CC - 50mA < IIN ADC < IIN_CC + 50mA  */
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"End(valid): ta_vol=%u low_ibat=%d\n",
				pca9468->ta_vol, ibat < ibat_limit);

		/* Check the current charging state */
		if (pca9468->charging_state == DC_STATE_CC_MODE) {
			pca9468->timer_id = TIMER_CHECK_CCMODE;
			pca9468->timer_period = PCA9468_CCMODE_CHECK1_T;
		} else {
			pca9468->timer_id = TIMER_CHECK_CVMODE;
			pca9468->timer_period = PCA9468_CVMODE_CHECK_T;
		}
	}

	return 0;
}

/* hold mutex_lock(&pca9468->lock), schedule on return 0 */
static int pca9468_set_rx_voltage_comp(struct pca9468_charger *pca9468)
{
	int rc, ibat, icn = -EINVAL, iin = -EINVAL;
	bool ovc_flag;

	pr_debug("%s: ======START=======\n", __func__);

	rc = pca9468_get_ibatt(pca9468, &ibat);
	if (rc == 0)
		rc = pca9468_get_iin(pca9468, &icn);
	if (rc == 0)
		iin = pca9468_read_adc(pca9468, ADCCH_IIN);

	ovc_flag = ibat > pca9468->cc_max;
	if (ovc_flag)
		p9468_chg_stats_inc_ovcf(&pca9468->chg_data, ibat, pca9468->cc_max);;

	logbuffer_prlog(pca9468, ovc_flag ? LOGLEVEL_WARNING : LOGLEVEL_DEBUG,
			"%s: iin=%d, iin_cc=[%d,%d,%d], icn=%d ibat=%d, cc_max=%d rc=%d",
			__func__, iin,
			pca9468->iin_cc - pca9468->pdata->iin_cc_comp_offset,
			pca9468->iin_cc,
			pca9468->iin_cc + pca9468->pdata->iin_cc_comp_offset,
			icn, ibat, pca9468->cc_max, rc);
	if (iin < 0)
		return iin;

	/* Compare IIN ADC with target input current */
	if (iin > (pca9468->iin_cc + pca9468->pdata->iin_cc_comp_offset)) {

		/* RX current is higher than the target input current */
		pca9468->ta_vol = pca9468->ta_vol - WCRX_VOL_STEP;
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont1: rx_vol=%u",
				pca9468->ta_vol);

		/* Set RX Voltage */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;

	} else if (iin < (pca9468->iin_cc - pca9468->pdata->iin_cc_comp_offset)) {

		/* RX current is lower than the target input current */
		/* Compare RX max voltage */
		if (pca9468->ta_vol == pca9468->ta_max_vol) {

			/* TA current is already the maximum voltage */
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"End1(max RX vol): rx_vol=%u",
					pca9468->ta_vol);

			/* Check the current charging state */
			if (pca9468->charging_state == DC_STATE_CC_MODE) {
				/* CC mode */
				pca9468->timer_id = TIMER_CHECK_CCMODE;
				pca9468->timer_period = PCA9468_CCMODE_CHECK1_T;
			} else {
				/* CV mode */
				pca9468->timer_id = TIMER_CHECK_CVMODE;
				pca9468->timer_period = PCA9468_CVMODE_CHECK_T;
			}
		} else {
			/* Increase RX voltage (100mV) */
			pca9468->ta_vol = pca9468->ta_vol + WCRX_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont2: rx_vol=%u",
					pca9468->ta_vol);

			/* Set RX Voltage */
			pca9468->timer_id = TIMER_PDMSG_SEND;
			pca9468->timer_period = 0;
		}
	} else {
		/* IIN ADC is in valid range */
		/* IIN_CC - 50mA < IIN ADC < IIN_CC + 50mA  */
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "End(valid): rx_vol=%u",
				pca9468->ta_vol);

		if (pca9468->charging_state == DC_STATE_CC_MODE) {
			pca9468->timer_id = TIMER_CHECK_CCMODE;
			pca9468->timer_period = PCA9468_CCMODE_CHECK1_T;
		} else {
			pca9468->timer_id = TIMER_CHECK_CVMODE;
			pca9468->timer_period = PCA9468_CVMODE_CHECK_T;
		}
	}

	return 0;
}

/*
 * iin limit for 2:1 for the adapter and chg_mode
 * Minimum between the confguration, cc_max (scaled with offset) and the
 * adapter capabilities.
 */
static int pca9468_get_iin_limit(const struct pca9468_charger *pca9468)
{
	int iin_cc;

	iin_cc = pca9468_get_iin_max(pca9468, pca9468->cc_max);
	if (pca9468->ta_max_cur * pca9468->chg_mode < iin_cc)
		iin_cc = pca9468->ta_max_cur * pca9468->chg_mode;

	pr_debug("%s: iin_cc=%d ta_max_cur=%u, chg_mode=%d\n", __func__,
		 iin_cc, pca9468->ta_max_cur, pca9468->chg_mode);

	return iin_cc;
}

/* recalculate ->ta_vol looking at demand (cc_max) */
static int pca9468_set_wireless_dc(struct pca9468_charger *pca9468, int vbat)
{
	unsigned long val;

	pca9468->iin_cc = pca9468_get_iin_limit(pca9468);

	/* RX_vol = MAX[(2*VBAT_ADC*CHG_mode + 500mV), 8.0V*CHG_mode] */
	pca9468->ta_vol = max(PCA9468_TA_MIN_VOL_PRESET * pca9468->chg_mode,
				(2 * vbat *  pca9468->chg_mode +
				PCA9468_TA_VOL_PRE_OFFSET));

	/* RX voltage resolution is 100mV */
	val = pca9468->ta_vol / WCRX_VOL_STEP;
	pca9468->ta_vol = val * WCRX_VOL_STEP;
	/* Set RX voltage to MIN[RX voltage, RX_MAX_VOL*chg_mode] */
	pca9468->ta_vol = min(pca9468->ta_vol, pca9468->ta_max_vol);

	/* ta_cur is ignored */
	logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
			"%s: iin_cc=%d, ta_vol=%d ta_max_vol=%d", __func__,
			pca9468->iin_cc, pca9468->ta_vol, pca9468->ta_max_vol);

	return 0;
}

/* recalculate ->ta_vol and ->ta_cur looking at demand (cc_max) */
static int pca9468_set_wired_dc(struct pca9468_charger *pca9468, int vbat)
{
	unsigned long val;
	int iin_cc;

	pca9468->iin_cc = pca9468_get_iin_limit(pca9468);

	/* Calculate new TA max voltage, current */
	val = pca9468->iin_cc / PD_MSG_TA_CUR_STEP;
	iin_cc = val * PD_MSG_TA_CUR_STEP;

	val = pca9468->ta_max_pwr / (iin_cc / pca9468->chg_mode  / 1000); /* mV */

	/* Adjust values with APDO resolution(20mV) */
	val = val * 1000 / PD_MSG_TA_VOL_STEP;
	val = val * PD_MSG_TA_VOL_STEP; /* uV */
	pca9468->ta_max_vol = min(val, (unsigned long)PCA9468_TA_MAX_VOL *
				  pca9468->chg_mode);

	/* MAX[8000mV * chg_mode, 2 * VBAT_ADC * chg_mode + 500 mV] */
	pca9468->ta_vol = max(PCA9468_TA_MIN_VOL_PRESET * pca9468->chg_mode,
			      2 * vbat * pca9468->chg_mode + PCA9468_TA_VOL_PRE_OFFSET);

	/* PPS voltage resolution is 20mV */
	val = pca9468->ta_vol / PD_MSG_TA_VOL_STEP;
	pca9468->ta_vol = val * PD_MSG_TA_VOL_STEP;
	pca9468->ta_vol = min(pca9468->ta_vol, pca9468->ta_max_vol);
	/* Set TA current to IIN_CC */
	pca9468->ta_cur = iin_cc / pca9468->chg_mode;

	logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
			"%s: iin_cc=%d, ta_vol=%d ta_cur=%d ta_max_vol=%d",
			__func__, pca9468->iin_cc, pca9468->ta_vol, pca9468->ta_cur,
			pca9468->ta_max_vol);

	return 0;
}

/*
 * like pca9468_preset_dcmode() but will not query the TA.
 * Called from timer:
 * [pca9468_charge_ccmode | pca9468_charge_cvmode] ->
 * 	pca9468_apply_new_iin() ->
 * 		pca9468_adjust_ta_current() ->
 * 			pca9468_reset_dcmode()
 * 	pca9468_apply_new_vfloat() ->
 * 		pca9468_reset_dcmode()
 *
 * NOTE: caller holds mutex_lock(&pca9468->lock);
 */
static int pca9468_reset_dcmode(struct pca9468_charger *pca9468)
{
	int ret = -EINVAL, vbat;

	pr_debug("%s: ======START=======\n", __func__);
	pr_debug("%s: = charging_state=%u == \n", __func__,
		 pca9468->charging_state);

	if (pca9468->cc_max < 0) {
		pr_err("%s: invalid cc_max=%d\n", __func__, pca9468->cc_max);
		goto error;
	}

	/*
	 * VBAT is over threshold but it might be "bouncy" due to transitory
	 * used to determine ta_vout.
	 */
	vbat = pca9468_read_adc(pca9468, ADCCH_VBAT);
	if (vbat < 0)
		return vbat;

	/* Check the TA type and set the charging mode */
	if (pca9468->ta_type == TA_TYPE_WIRELESS) {
		ret = pca9468_set_wireless_dc(pca9468, vbat);
	} else {
		ret = pca9468_set_wired_dc(pca9468, vbat);
	}

	/* Clear previous IIN ADC, TA increment flag */
	pca9468->prev_inc = INC_NONE;
	pca9468->prev_iin = 0;
error:
	pr_debug("%s: End, ret=%d\n", __func__, ret);
	return ret;
}

/*
 * The caller was triggered from pca9468_apply_new_iin(), return to the
 * calling CC or CV loop.
 * call holding mutex_unlock(&pca9468->lock);
 */
static void pca9468_return_to_loop(struct pca9468_charger *pca9468)
{
	switch (pca9468->ret_state) {
	case DC_STATE_CC_MODE:
		pca9468->timer_id = TIMER_CHECK_CCMODE;
		break;
	case DC_STATE_CV_MODE:
		pca9468->timer_id = TIMER_CHECK_CVMODE;
		break;
	default:
		dev_err(pca9468->dev, "%s: invalid ret_state=%u\n",
			__func__, pca9468->ret_state);
		return;
	}

	dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
		 pca9468->charging_state, pca9468->ret_state);

	pca9468->charging_state = pca9468->ret_state;
	pca9468->timer_period = 1000;
	pca9468->ret_state = 0;
	pca9468->new_iin = 0;
}

/*
 * Kicked from pca9468_apply_new_iin() when pca9468->new_iin!=0 and completed
 * off the timer. Never called on WLC_DC.
 * NOTE: Will return to the calling loop in ->ret_state
 */
static int pca9468_adjust_ta_current(struct pca9468_charger *pca9468)
{
	const int ta_limit = pca9468->iin_cc / pca9468->chg_mode;
	int rc, ibat, icn = -EINVAL, iin = -EINVAL;
	bool ovc_flag;
	int ret = 0;

	rc = pca9468_get_ibatt(pca9468, &ibat);
	if (rc == 0)
		rc = pca9468_get_iin(pca9468, &icn);
	if (rc == 0)
		iin = pca9468_read_adc(pca9468, ADCCH_IIN);

	ovc_flag = ibat > pca9468->cc_max;
	if (ovc_flag)
		p9468_chg_stats_inc_ovcf(&pca9468->chg_data, ibat, pca9468->cc_max);;

	logbuffer_prlog(pca9468, ovc_flag ? LOGLEVEL_WARNING : LOGLEVEL_DEBUG,
			"%s: iin=%d, iin_cc=%d ta_limit=%d, iin_cfg=%d icn=%d ibat=%d, cc_max=%d rc=%d",
			__func__, iin, pca9468->iin_cc, ta_limit, pca9468->pdata->iin_cfg,
			icn, ibat, pca9468->cc_max, rc);

	if (pca9468->charging_state != DC_STATE_ADJUST_TACUR)
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_ADJUST_TACUR);

	pca9468->charging_state = DC_STATE_ADJUST_TACUR;

	if (pca9468->ta_cur == ta_limit) {

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"adj. End, ta_cur=%u, ta_vol=%u, iin_cc=%u, chg_mode=%u",
				pca9468->ta_cur, pca9468->ta_vol,
				pca9468->iin_cc, pca9468->chg_mode);

		/* "Recover" IIN_CC to the original value (new_iin) */
		pca9468->iin_cc = pca9468->new_iin;
		pca9468_return_to_loop(pca9468);

	} else if (pca9468->iin_cc > pca9468->pdata->iin_cfg) {
		const int old_iin_cfg = pca9468->pdata->iin_cfg;

		/* Raise iin_cfg to the new iin_cc value (why??!?!?) */
		pca9468->pdata->iin_cfg = pca9468->iin_cc;

		ret = pca9468_set_input_current(pca9468, pca9468->iin_cc);
		if (ret == 0)
			ret = pca9468_reset_dcmode(pca9468);
		if (ret < 0)
			goto error;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"New IIN, ta_max_vol=%u, ta_max_cur=%u, ta_max_pwr=%lu, iin_cc=%u, iin_cfg=%d->%d chg_mode=%u",
				pca9468->ta_max_vol, pca9468->ta_max_cur,
				pca9468->ta_max_pwr, pca9468->iin_cc,
				old_iin_cfg, pca9468->iin_cc,
				pca9468->chg_mode);

		pca9468->new_iin = 0;

		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_ADJUST_CC);

		/* Send PD Message and go to Adjust CC mode */
		pca9468->charging_state = DC_STATE_ADJUST_CC;
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
	} else {
		unsigned int val;

		/*
		 * Adjust IIN_CC with APDO resolution(50mA)
		 * pca9468->iin_cc will be reset to pca9468->new_iin when
		 * ->ta_cur reaches the ta_limit at the beginning of the
		 * function
		 */
		val = pca9468->iin_cc / PD_MSG_TA_CUR_STEP;
		pca9468->iin_cc = val * PD_MSG_TA_CUR_STEP;
		pca9468->ta_cur = pca9468->iin_cc / pca9468->chg_mode;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "adjust iin=%u ta_cur=%d chg_mode=%d",
				pca9468->iin_cc, pca9468->ta_cur, pca9468->chg_mode);

		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
	}

	/* reschedule on ret == 0 */
error:
	return ret;
}

/* Kicked from apply_new_iin() then run off the timer
 * call holding mutex_lock(&pca9468->lock);
 */
static int pca9468_adjust_ta_voltage(struct pca9468_charger *pca9468)
{
	int rc, ibat, icn = -EINVAL, iin = -EINVAL;
	bool ovc_flag;

	if (pca9468->charging_state != DC_STATE_ADJUST_TAVOL)
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_ADJUST_TAVOL);

	pca9468->charging_state = DC_STATE_ADJUST_TAVOL;

	rc = pca9468_get_ibatt(pca9468, &ibat);
	if (rc == 0)
		rc = pca9468_get_iin(pca9468, &icn);
	if (rc == 0)
		iin = pca9468_read_adc(pca9468, ADCCH_IIN);

	ovc_flag = ibat > pca9468->cc_max;
	if (ovc_flag)
		p9468_chg_stats_inc_ovcf(&pca9468->chg_data, ibat, pca9468->cc_max);;

	logbuffer_prlog(pca9468, ovc_flag ? LOGLEVEL_WARNING : LOGLEVEL_DEBUG,
			"%s: iin=%d, iin_cc=[%d,%d,%d], icn=%d ibat=%d, cc_max=%d rc=%d",
			__func__, iin, pca9468->iin_cc - PD_MSG_TA_CUR_STEP,
			pca9468->iin_cc, pca9468->iin_cc + PD_MSG_TA_CUR_STEP,
			icn, ibat, pca9468->cc_max, rc);

	if (iin < 0)
		return iin;


	/* Compare IIN ADC with targer input current */
	if (iin > (pca9468->iin_cc + PD_MSG_TA_CUR_STEP)) {
		/* TA current is higher than the target input current */
		/* Decrease TA voltage (20mV) */
		pca9468->ta_vol = pca9468->ta_vol - PD_MSG_TA_VOL_STEP;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont1, ta_vol=%u",
				pca9468->ta_vol);

		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
	} else if (iin < (pca9468->iin_cc - PD_MSG_TA_CUR_STEP)) {
		/* TA current is lower than the target input current */

		if (pca9468_check_status(pca9468) == STS_MODE_VFLT_LOOP) {
			/* IIN current may not able to increase in CV */

			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"End1-1, skip adjust for cv, ta_cur=%u, ta_vol=%u, iin_cc=%u, chg_mode=%u",
					pca9468->ta_cur, pca9468->ta_vol,
					pca9468->iin_cc, pca9468->chg_mode);

			pca9468_return_to_loop(pca9468);
		} else if (pca9468->ta_vol == pca9468->ta_max_vol) {
			/* TA TA voltage is already at the maximum voltage */

			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"End1, ta_cur=%u, ta_vol=%u, iin_cc=%u, chg_mode=%u",
					pca9468->ta_cur, pca9468->ta_vol,
					pca9468->iin_cc, pca9468->chg_mode);

			pca9468_return_to_loop(pca9468);
		} else {
			/* Increase TA voltage (20mV) */
			pca9468->ta_vol = pca9468->ta_vol + PD_MSG_TA_VOL_STEP;

			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont2, ta_vol=%u",
					pca9468->ta_vol);

			/* Send PD Message */
			pca9468->timer_id = TIMER_PDMSG_SEND;
			pca9468->timer_period = 0;
		}
	} else {
		/* IIN ADC is in valid range */
		/* IIN_CC - 50mA < IIN ADC < IIN_CC + 50mA  */

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"End2, ta_cur=%u, ta_vol=%u, iin_cc=%u, chg_mode=%u",
				pca9468->ta_cur, pca9468->ta_vol,
			pca9468->iin_cc, pca9468->chg_mode);

		pca9468_return_to_loop(pca9468);
	}

	return 0;
}

/*
 * Kicked from apply_new_iin() then run off the timer
 * * NOTE: caller must hold mutex_lock(&pca9468->lock)
 */
static int pca9468_adjust_rx_voltage(struct pca9468_charger *pca9468)
{
	const int iin_high = pca9468->iin_cc + pca9468->pdata->iin_cc_comp_offset;
	const int iin_low = pca9468->iin_cc - pca9468->pdata->iin_cc_comp_offset;
	int rc, ibat, icn = -EINVAL, iin = -EINVAL;
	bool ovc_flag;

	if (pca9468->charging_state != DC_STATE_ADJUST_TAVOL)
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_ADJUST_TAVOL);

	pca9468->charging_state = DC_STATE_ADJUST_TAVOL;

	rc = pca9468_get_ibatt(pca9468, &ibat);
	if (rc == 0)
		rc = pca9468_get_iin(pca9468, &icn);
	if (rc == 0)
		iin = pca9468_read_adc(pca9468, ADCCH_IIN);

	ovc_flag = ibat > pca9468->cc_max;
	if (ovc_flag)
		p9468_chg_stats_inc_ovcf(&pca9468->chg_data, ibat, pca9468->cc_max);;

	logbuffer_prlog(pca9468, ovc_flag ? LOGLEVEL_WARNING : LOGLEVEL_DEBUG,
			"%s: iin=%d, iin_cc=[%d,%d,%d], icn=%d ibat=%d, cc_max=%d rc=%d",
			__func__, iin, iin_low, pca9468->iin_cc, iin_high,
			icn, ibat, pca9468->cc_max, rc);

	if (iin < 0)
		return iin;

	/* Compare IIN ADC with targer input current */
	if (iin > iin_high) {
		/* RX current is higher than the target input current */

		/* Decrease RX voltage (100mV) */
		pca9468->ta_vol = pca9468->ta_vol - WCRX_VOL_STEP;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont1, rx_vol=%u",
				pca9468->ta_vol);

		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
	} else if (iin < iin_low) {
		/* RX current is lower than the target input current */

		if (pca9468_check_status(pca9468) == STS_MODE_VFLT_LOOP) {
			/* RX current may not able to increase in CV */
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"End1-1, skip adjust for cv, rx_vol=%u, iin_cc=%u",
					pca9468->ta_vol, pca9468->iin_cc);

			pca9468_return_to_loop(pca9468);
		} else if (pca9468->ta_vol == pca9468->ta_max_vol) {
			/* RX current is already the maximum voltage */
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"End1, rx_vol=%u, iin_cc=%u, chg_mode=%u",
					pca9468->ta_vol, pca9468->iin_cc,
					pca9468->chg_mode);

			/* Return charging state to the previous state */
			pca9468_return_to_loop(pca9468);
		} else {
			/* Increase RX voltage (100mV) */
			pca9468->ta_vol = pca9468->ta_vol + WCRX_VOL_STEP;

			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont2, rx_vol=%u",
					pca9468->ta_vol);

			/* Set RX voltage */
			pca9468->timer_id = TIMER_PDMSG_SEND;
			pca9468->timer_period = 0;
		}
	} else {
		/* IIN ADC is in valid range */

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"End2, rx_vol=%u, iin_cc=%u, chg_mode=%u",
				pca9468->ta_vol, pca9468->iin_cc,
				pca9468->chg_mode);

		/* Return charging state to the previous state */
		pca9468_return_to_loop(pca9468);
	}

	return 0;
}

/*
 * Called from CC and CV loops to set a new IIN (i.e. a new cc_max charging
 * current). Should also change the iin_cfg to avoid overcurrents.
 * NOTE: caller must hold mutex_lock(&pca9468->lock)
 */
static int pca9468_apply_new_iin(struct pca9468_charger *pca9468)
{
	int ret;

	logbuffer_prlog(pca9468, LOGLEVEL_INFO,
			"new_iin=%d (cc_max=%d), ta_type=%d charging_state=%d",
			pca9468->new_iin, pca9468->cc_max,
			pca9468->ta_type, pca9468->charging_state);

	/* iin_cfg is adjusted UP in pca9468_set_input_current() */
	ret = pca9468_set_input_current(pca9468, pca9468->new_iin);
	if (ret < 0)
		return ret;
	pca9468->pdata->iin_cfg = pca9468->new_iin;

	 /*
	  * ->ret_state is used to go back to the loop (CC or CV) that called
	  * this function.
	  */
	pca9468->ret_state = pca9468->charging_state;

	/*
	 * new_iin is used to trigger the process which might span one or more
	 * timer ticks the new_iin . The flag will be cleared once the target
	 * is reached.
	 */
	pca9468->iin_cc = pca9468->new_iin;
	if (pca9468->ta_type == TA_TYPE_WIRELESS) {
		ret = pca9468_adjust_rx_voltage(pca9468);
	} else if (pca9468->iin_cc < (PCA9468_TA_MIN_CUR * pca9468->chg_mode)) {
		/* TA current = PCA9468_TA_MIN_CUR(1.0A) */
		pca9468->ta_cur = PCA9468_TA_MIN_CUR;
		ret = pca9468_adjust_ta_voltage(pca9468);
	} else {
		ret = pca9468_adjust_ta_current(pca9468);
	}

	/* need reschedule on ret != 0 */

	pr_debug("%s: ret=%d\n", __func__, ret);
	return ret;
}

/*
 * also called from pca9468_set_new_cc_max()
 * call holding mutex_unlock(&pca9468->lock);
 */
static int pca9468_set_new_iin(struct pca9468_charger *pca9468, int iin)
{
	int ret = 0;

	if (iin < 0) {
		pr_debug("%s: ignore negative iin=%d\n", __func__, iin);
		return 0;
	}

	/* same as previous request nevermind */
	if (iin == pca9468->new_iin)
		return 0;

	pr_debug("%s: new_iin=%d->%d state=%d\n", __func__,
		 pca9468->new_iin, iin, pca9468->charging_state);

	/* apply iin_cc in pca9468_preset_config() at start */
	if (pca9468->charging_state == DC_STATE_NO_CHARGING ||
	    pca9468->charging_state == DC_STATE_CHECK_VBAT) {

		/* used on start vs the ->iin_cfg one */
		pca9468->pdata->iin_cfg = iin;
		pca9468->iin_cc = iin;
	} else if (pca9468->ret_state == 0) {
		/*
		 * pca9468_apply_new_iin() has not picked out the value yet
		 * and the value can be changed safely.
		 */
		pca9468->new_iin = iin;

		/* might want to tickle the loop now */
	} else {
		/* the caller must retry */
		ret = -EAGAIN;
	}

	pr_debug("%s: ret=%d\n", __func__, ret);
	return ret;
}

/*
 * The is no CC loop in this part: current must be controlled on TA side
 * adjusting output power. cc_max (the charging current) is scaled to iin
 *
 */
static int pca9468_set_new_cc_max(struct pca9468_charger *pca9468, int cc_max)
{
	const int prev_cc_max = pca9468->cc_max;
	int iin_max, ret = 0;

	if (cc_max < 0) {
		pr_debug("%s: ignore negative cc_max=%d\n", __func__, cc_max);
		return 0;
	}

	mutex_lock(&pca9468->lock);

	/* same as previous request nevermind */
	if (cc_max == pca9468->cc_max)
		goto done;

	/* iin will be capped by the adapter capabilities in reset_dcmode() */
	iin_max = pca9468_get_iin_max(pca9468, cc_max);
	if (iin_max <= 0) {
		pr_debug("%s: ignore negative iin_max=%d\n", __func__, iin_max);
		goto done;
	}

	ret = pca9468_set_new_iin(pca9468, iin_max);
	if (ret == 0)
		pca9468->cc_max = cc_max;

	logbuffer_prlog(pca9468, LOGLEVEL_INFO,
			"%s: charging_state=%d cc_max=%d->%d iin_max=%d, ret=%d",
			__func__, pca9468->charging_state, prev_cc_max,
			cc_max, iin_max, ret);

done:
	pr_debug("%s: ret=%d\n", __func__, ret);
	mutex_unlock(&pca9468->lock);
	return ret;
}

/*
 * Apply pca9468->new_vfloat to the charging voltage.
 * Called from CC and CV loops, needs mutex_lock(&pca9468->lock)
 */
static int pca9468_apply_new_vfloat(struct pca9468_charger *pca9468)
{
	int fv_uv, ret = 0;

	/* compensated float voltage, -EINVAL if under pca_vbat */
	fv_uv = pca9468_apply_irdrop(pca9468, pca9468->new_vfloat);
	if (fv_uv < 0)
		return fv_uv;

	/* actually change the hardware */
	ret = pca9468_set_vfloat(pca9468, fv_uv);
	if (ret < 0)
		goto error_done;

	/* Restart the process (TODO: optimize this) */
	ret = pca9468_reset_dcmode(pca9468);
	if (ret < 0) {
		pr_err("%s: cannot reset dcmode (%d)\n", __func__, ret);
	} else {
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_ADJUST_CC);

		pca9468->charging_state = DC_STATE_ADJUST_CC;
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
	}

error_done:
	logbuffer_prlog(pca9468, LOGLEVEL_INFO,
			"%s: new_vfloat=%d, fv_uv=%d ret=%d", __func__,
			pca9468->new_vfloat, fv_uv, ret);

	if (ret == 0)
		pca9468->new_vfloat = 0;

	return ret;
}

static int pca9468_set_new_vfloat(struct pca9468_charger *pca9468, int vfloat)
{
	int ret = 0;

	if (vfloat < 0) {
		pr_debug("%s: ignore negative vfloat %d\n", __func__, vfloat);
		return 0;
	}

	mutex_lock(&pca9468->lock);
	if (pca9468->fv_uv == vfloat)
		goto done;

	/* this is what is requested */
	pca9468->fv_uv = vfloat;

	/* use fv_uv at start in pca9468_preset_config() */
	if (pca9468->charging_state == DC_STATE_NO_CHARGING ||
	    pca9468->charging_state == DC_STATE_CHECK_VBAT) {
		// pca9468->pdata->v_float = vfloat;
	} else {
		/* applied in pca9468_apply_new_vfloat() from CC or in CV loop */
		pca9468->new_vfloat = vfloat;

		/* might want to tickle the cycle */
	}

done:
	mutex_unlock(&pca9468->lock);
	return ret;
}

/* called on loop inactive */
static int pca9468_ajdust_ccmode_wireless(struct pca9468_charger *pca9468, int iin)
{
	/* IIN_ADC > IIN_CC -20mA ? */
	if (iin > (pca9468->iin_cc - PCA9468_IIN_ADC_OFFSET)) {
		/* Input current is already over IIN_CC */
		/* End RX voltage adjustment */

		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_CC_MODE);

		/* change charging state to CC mode */
		pca9468->charging_state = DC_STATE_CC_MODE;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "End1: IIN_ADC=%d, rx_vol=%u",
				iin, pca9468->ta_vol);

		/* Clear TA increment flag */
		pca9468->prev_inc = INC_NONE;
		/* Go to CC mode */
		pca9468->timer_id = TIMER_CHECK_CCMODE;
		pca9468->timer_period = 0;

	/* Check RX voltage */
	} else if (pca9468->ta_vol == pca9468->ta_max_vol) {
		/* RX voltage is already max value */
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,"End2: MAX value, rx_vol=%u max=%d",
				pca9468->ta_vol, pca9468->ta_max_vol);

		/* Clear TA increment flag */
		pca9468->prev_inc = INC_NONE;
		/* Go to CC mode */
		pca9468->timer_id = TIMER_CHECK_CCMODE;
		pca9468->timer_period = 0;
	} else {
		/* Try to increase RX voltage(100mV) */
		pca9468->ta_vol = pca9468->ta_vol + WCRX_VOL_STEP;
		if (pca9468->ta_vol > pca9468->ta_max_vol)
			pca9468->ta_vol = pca9468->ta_max_vol;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont: rx_vol=%u",
				pca9468->ta_vol);
		/* Set RX voltage */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
	}

	return 0;
}

/* called on loop inactive */
static int pca9468_ajdust_ccmode_wired(struct pca9468_charger *pca9468, int iin)
{

	/* USBPD TA is connected */
	if (iin > (pca9468->iin_cc - PCA9468_IIN_ADC_OFFSET)) {
		/* IIN_ADC > IIN_CC -20mA ? */
		/* Input current is already over IIN_CC */
		/* End TA voltage and current adjustment */

		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_CC_MODE);

		/* change charging state to CC mode */
		pca9468->charging_state = DC_STATE_CC_MODE;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"End1: IIN_ADC=%d, ta_vol=%u, ta_cur=%u",
				iin, pca9468->ta_vol, pca9468->ta_cur);

		/* Clear TA increment flag */
		pca9468->prev_inc = INC_NONE;
		/* Go to CC mode */
		pca9468->timer_id = TIMER_CHECK_CCMODE;
		pca9468->timer_period = 0;

	/* Check TA voltage */
	} else if (pca9468->ta_vol == pca9468->ta_max_vol) {
		/* TA voltage is already max value */
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"End2: MAX value, ta_vol=%u, ta_cur=%u",
				pca9468->ta_vol, pca9468->ta_cur);

		/* Clear TA increment flag */
		pca9468->prev_inc = INC_NONE;
		/* Go to CC mode */
		pca9468->timer_id = TIMER_CHECK_CCMODE;
		pca9468->timer_period = 0;

		/* Check TA tolerance
		 * The current input current compares the final input
		 * current(IIN_CC) with 100mA offset PPS current tolerance
		 * has +/-150mA, so offset defined 100mA(tolerance +50mA)
		 */
	} else if (iin < (pca9468->iin_cc - PCA9468_TA_IIN_OFFSET)) {
		/*
		 * TA voltage too low to enter TA CC mode, so we
		 * should increase TA voltage
		 */
		pca9468->ta_vol = pca9468->ta_vol + PCA9468_TA_VOL_STEP_ADJ_CC *
					pca9468->chg_mode;

		if (pca9468->ta_vol > pca9468->ta_max_vol)
			pca9468->ta_vol = pca9468->ta_max_vol;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont1: ta_vol=%u",
				pca9468->ta_vol);

		/* Set TA increment flag */
		pca9468->prev_inc = INC_TA_VOL;
		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;

	/* compare IIN ADC with previous IIN ADC + 20mA */
	} else if (iin > (pca9468->prev_iin + PCA9468_IIN_ADC_OFFSET)) {
		/* TA can supply more current if TA voltage is high */
		/* TA voltage too low for TA CC mode: increase it */
		pca9468->ta_vol = pca9468->ta_vol +
					PCA9468_TA_VOL_STEP_ADJ_CC *
					pca9468->chg_mode;
		if (pca9468->ta_vol > pca9468->ta_max_vol)
			pca9468->ta_vol = pca9468->ta_max_vol;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont2: ta_vol=%u",
				pca9468->ta_vol);
		/* Set TA increment flag */
		pca9468->prev_inc = INC_TA_VOL;

		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;

	/* Check the previous increment */
	} else if (pca9468->prev_inc == INC_TA_CUR) {
		/*
		 * The previous increment is TA current, but input
		 * current does not increase. Try with voltage.
		 */

		pca9468->ta_vol = pca9468->ta_vol +
					PCA9468_TA_VOL_STEP_ADJ_CC *
					pca9468->chg_mode;
		if (pca9468->ta_vol > pca9468->ta_max_vol)
			pca9468->ta_vol = pca9468->ta_max_vol;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont3: ta_vol=%u",
				pca9468->ta_vol);

		pca9468->prev_inc = INC_TA_VOL;
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;

		/*
		 * The previous increment is TA voltage, but input
		 * current does not increase
		 */

		/* Try to increase TA current */
		/* Check APDO max current */
	} else if (pca9468->ta_cur == pca9468->ta_max_cur) {
		/* TA current is maximum current */

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"End(MAX_CUR): IIN_ADC=%d, ta_vol=%u, ta_cur=%u",
				iin, pca9468->ta_vol, pca9468->ta_cur);

		pca9468->prev_inc = INC_NONE;

		/* Go to CC mode */
		pca9468->timer_id = TIMER_CHECK_CCMODE;
		pca9468->timer_period = 0;
	} else {
		/* TA has tolerance and compensate it as real current */
		/* Increase TA current(50mA) */
		pca9468->ta_cur = pca9468->ta_cur + PD_MSG_TA_CUR_STEP;
		if (pca9468->ta_cur > pca9468->ta_max_cur)
			pca9468->ta_cur = pca9468->ta_max_cur;

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "Cont4: ta_cur=%u",
				pca9468->ta_cur);

		pca9468->prev_inc = INC_TA_CUR;
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
	}

	return 0;
}


/* 2:1 Direct Charging Adjust CC MODE control
 * called at the beginnig of CC mode charging. Will be followed by
 * pca9468_charge_ccmode with wich share some of the adjustments.
 */
static int pca9468_charge_adjust_ccmode(struct pca9468_charger *pca9468)
{
	int  iin, ccmode, vbatt, vin_vol;
	bool apply_ircomp = false;
	int ret = 0;

	mutex_lock(&pca9468->lock);

	pr_debug("%s: ======START=======\n", __func__);
	pca9468_prlog_state(pca9468, __func__);

	if (pca9468->charging_state != DC_STATE_ADJUST_CC)
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_ADJUST_CC);

	pca9468->charging_state = DC_STATE_ADJUST_CC;

	ret = pca9468_check_error(pca9468);
	if (ret != 0)
		goto error; // This is not active mode.

	ccmode = pca9468_check_status(pca9468);
	if (ccmode < 0) {
		ret = ccmode;
		goto error;
	}

	switch(ccmode) {
	case STS_MODE_IIN_LOOP:
	case STS_MODE_CHG_LOOP:	/* CHG_LOOP does't exist */
		apply_ircomp = true;

		if (pca9468->ta_type == TA_TYPE_WIRELESS) {
			/* Decrease RX voltage (100mV) */
			pca9468->ta_vol = pca9468->ta_vol - WCRX_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "End1: rx_vol=%u",
					 pca9468->ta_vol);
		} else if (pca9468->ta_cur > PCA9468_TA_MIN_CUR) {
			/* TA current is higher than 1.0A */
			/* Decrease TA current (50mA) */
			pca9468->ta_cur = pca9468->ta_cur - PD_MSG_TA_CUR_STEP;

			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "End2: ta_cur=%u, ta_vol=%u",
					pca9468->ta_cur, pca9468->ta_vol);
		} else {
			/* Decrease TA voltage (20mV) */
			pca9468->ta_vol = pca9468->ta_vol - PD_MSG_TA_VOL_STEP;

			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "End3: ta_cur=%u, ta_vol=%u",
					pca9468->ta_cur, pca9468->ta_vol);
		}

		pca9468->prev_inc = INC_NONE;

		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_CC_MODE);

		/* Send PD Message and then go to CC mode */
		pca9468->charging_state = DC_STATE_CC_MODE;
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
		break;

	case STS_MODE_VFLT_LOOP:
		vbatt = pca9468_read_adc(pca9468, ADCCH_VBAT);

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "End4: vbatt=%d, ta_vol=%u",
				vbatt, pca9468->ta_vol);

		/* Clear TA increment flag */
		pca9468->prev_inc = INC_NONE;
		/* Go to Pre-CV mode */
		pca9468->timer_id = TIMER_ENTER_CVMODE;
		pca9468->timer_period = 0;
		break;

	case STS_MODE_LOOP_INACTIVE:

		iin = pca9468_read_adc(pca9468, ADCCH_IIN);
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"Inactive: iin=%d, iin_cc=%d, cc_max=%d",
				iin, pca9468->iin_cc, pca9468->cc_max);
		if (iin < 0)
			break;

		if (pca9468->ta_type == TA_TYPE_WIRELESS) {
			ret = pca9468_ajdust_ccmode_wireless(pca9468, iin);
		} else {
			ret = pca9468_ajdust_ccmode_wired(pca9468, iin);
		}

		if (ret < 0) {
			pr_err("%s: %d", __func__, ret);
		} else {
			pca9468->prev_iin = iin;
			apply_ircomp = true;
		}

		break;

	case STS_MODE_VIN_UVLO:
		/* VIN UVLO - just notification , it works by hardware */
		vin_vol = pca9468_read_adc(pca9468, ADCCH_VIN);

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "VIN_UVLO: ta_vol=%u, vin_vol=%d",
				pca9468->ta_cur, vin_vol);

		/* Check VIN after 1sec */
		pca9468->timer_id = TIMER_ADJUST_CCMODE;
		pca9468->timer_period = 1000;
		break;

	default:
		goto error;
	}

	if (!pca9468->irdrop_comp_ok && apply_ircomp) {
		int rc;

		rc = pca9468_comp_irdrop(pca9468);
		if (rc < 0)
			pr_err("%s: cannot apply ircomp (%d)\n",
			       __func__, rc);
	}

	mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
			 msecs_to_jiffies(pca9468->timer_period));
error:
	mutex_unlock(&pca9468->lock);
	pr_debug("%s: End, ret=%d\n", __func__, ret);
	return ret;
}

/* <0 error, 0 no new limits, >0 new limits */
static int pca9468_apply_new_limits(struct pca9468_charger *pca9468)
{
	int ret = 0;

	if (pca9468->new_iin && pca9468->new_iin < pca9468->iin_cc) {
		ret = pca9468_apply_new_iin(pca9468);
		if (ret == 0)
			ret = 1;
	} else if (pca9468->new_vfloat) {
		ret = pca9468_apply_new_vfloat(pca9468);
		if (ret == 0)
			ret = 1;
	} else if (pca9468->new_iin) {
		ret = pca9468_apply_new_iin(pca9468);
		if (ret == 0)
			ret = 1;
	} else {
		return 0;
	}

	return ret;
}

/* 2:1 Direct Charging CC MODE control */
static int pca9468_charge_ccmode(struct pca9468_charger *pca9468)
{
	int ccmode, vin_vol, iin, ret = 0;
	bool apply_ircomp = false;

	pr_debug("%s: ======START======= \n", __func__);

	mutex_lock(&pca9468->lock);

	if (pca9468->charging_state != DC_STATE_CC_MODE)
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_CC_MODE);

	pca9468->charging_state = DC_STATE_CC_MODE;

	pca9468_prlog_state(pca9468, __func__);

	ret = pca9468_check_error(pca9468);
	if (ret != 0)
		goto error_exit;

	/*
	 * A change in VFLOAT here means that we have busted the tier, a
	 * change in iin means that the thermal engine had changed cc_max.
	 * pca9468_apply_new_limits() changes pca9468->charging_state to
	 * DC_STATE_ADJUST_TAVOL or DC_STATE_ADJUST_TACUR when new limits
	 * need to be applied.
	 */
	ret = pca9468_apply_new_limits(pca9468);
	if (ret < 0)
		goto error_exit;
	if (ret > 0)
		goto done;

	ccmode = pca9468_check_status(pca9468);
	if (ccmode < 0) {
		ret = ccmode;
		goto error_exit;
	}

	switch(ccmode) {
	case STS_MODE_LOOP_INACTIVE:

		/* Set input current compensation */
		if (pca9468->ta_type == TA_TYPE_WIRELESS) {
			/* Need RX voltage compensation */
			ret = pca9468_set_rx_voltage_comp(pca9468);

			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "INACTIVE1: rx_vol=%u",
					pca9468->ta_vol);
		} else {
			const int ta_max_vol = pca9468->ta_max_vol;

			/* Check TA current with TA_MIN_CUR */
			if (pca9468->ta_cur <= PCA9468_TA_MIN_CUR) {
				pca9468->ta_cur = PCA9468_TA_MIN_CUR;

				ret = pca9468_set_ta_voltage_comp(pca9468);
			} else if (ta_max_vol >= PCA9468_TA_MAX_VOL_CP) {
				ret = pca9468_set_ta_current_comp(pca9468);
			} else {
				/* constant power mode */
				ret = pca9468_set_ta_current_comp2(pca9468);
			}

			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"INACTIVE2: ta_cur=%u, ta_vol=%u",
					pca9468->ta_cur,
					pca9468->ta_vol);
		}

		if (ret == 0)
			apply_ircomp = true;
		break;

	case STS_MODE_VFLT_LOOP:
		/* TODO: adjust fv_uv here based on real vbatt */

		iin = pca9468_read_adc(pca9468, ADCCH_IIN);
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG, "CC VFLOAT: iin=%d", iin);

		/* go to Pre-CV mode */
		pca9468->timer_id = TIMER_ENTER_CVMODE;
		pca9468->timer_period = 0;
		break;

	case STS_MODE_IIN_LOOP:
	case STS_MODE_CHG_LOOP:
		iin = pca9468_read_adc(pca9468, ADCCH_IIN);
		if (iin < 0)
			break;

		if (pca9468->ta_type == TA_TYPE_WIRELESS) {
			/* Decrease RX voltage (100mV) */
			pca9468->ta_vol = pca9468->ta_vol - WCRX_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"IIN_LOOP1: iin=%d, next_rx_vol=%u",
					iin, pca9468->ta_vol);
		} else if (pca9468->ta_cur <= PCA9468_TA_MIN_CUR) {
			/* Decrease TA voltage (20mV) */
			pca9468->ta_vol = pca9468->ta_vol - PD_MSG_TA_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"IIN_LOOP2: iin=%d, next_ta_vol=%u",
					iin, pca9468->ta_vol);
		} else {
			/* Decrease TA current (50mA) */
			pca9468->ta_cur = pca9468->ta_cur - PD_MSG_TA_CUR_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"IIN_LOOP3: iin=%d, next_ta_cur=%u",
					iin, pca9468->ta_cur);
		}

		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
		break;

	case STS_MODE_VIN_UVLO:
		/* VIN UVLO - just notification, it works by hardware */
		vin_vol = pca9468_read_adc(pca9468, ADCCH_VIN);

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"VIN_UVLO: ta_cur=%u ta_vol=%u, vin_vol=%d",
				pca9468->ta_cur, pca9468->ta_vol, vin_vol);

		/* Check VIN after 1sec */
		pca9468->timer_id = TIMER_CHECK_CCMODE;
		pca9468->timer_period = 1000;
		break;

	default:
		break;
	}

	if (!pca9468->irdrop_comp_ok && apply_ircomp) {
		int rc;

		rc = pca9468_comp_irdrop(pca9468);
		if (rc < 0)
			pr_err("%s: cannot apply ircomp (%d)\n",
			       __func__, rc);
	}

done:
	mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
			 msecs_to_jiffies(pca9468->timer_period));

error_exit:
	mutex_unlock(&pca9468->lock);
	pr_debug("%s: End, ccmode=%d timer_id=%d, timer_period=%lu ret=%d\n",
		 __func__, ccmode, pca9468->timer_id, pca9468->timer_period,
		 ret);
	return ret;
}


/* 2:1 Direct Charging Start CV MODE control - Pre CV MODE */
static int pca9468_charge_start_cvmode(struct pca9468_charger *pca9468)
{
	int ret = 0;
	int cvmode;
	int vin_vol;

	pr_debug("%s: ======START=======\n", __func__);

	mutex_lock(&pca9468->lock);

	if (pca9468->charging_state != DC_STATE_START_CV)
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_START_CV);

	pca9468->charging_state = DC_STATE_START_CV;

	/* Check the charging type */
	ret = pca9468_check_error(pca9468);
	if (ret != 0)
		goto error_exit;

	/* Check the status */
	cvmode = pca9468_check_status(pca9468);
	if (cvmode < 0) {
		ret = cvmode;
		goto error_exit;
	}

	switch(cvmode) {
	case STS_MODE_CHG_LOOP:
	case STS_MODE_IIN_LOOP:

		if (pca9468->ta_type == TA_TYPE_WIRELESS) {
			/* Decrease RX voltage (100mV) */
			pca9468->ta_vol = pca9468->ta_vol - WCRX_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"%s: PreCV IIN_LOOP: rx_vol=%u",
				 __func__, pca9468->ta_vol);
		} else {
			/* Check TA current */
			if (pca9468->ta_cur > PCA9468_TA_MIN_CUR) {
				/* TA current is higher than 1.0A */

				/* Decrease TA current (50mA) */
				pca9468->ta_cur = pca9468->ta_cur - PD_MSG_TA_CUR_STEP;
				logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
						"%s: PreCV IIN_LOOP: ta_cur=%u",
						__func__, pca9468->ta_cur);
			} else {
				/* TA current is less than 1.0A */
				/* Decrease TA voltage (20mV) */
				pca9468->ta_vol = pca9468->ta_vol - PD_MSG_TA_VOL_STEP;
				logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
						"%s: PreCV IIN_LOOP: ta_vol=%u",
						__func__, pca9468->ta_vol);
			}
		}

		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
		break;

	case STS_MODE_VFLT_LOOP:
		/* Check the TA type */
		if (pca9468->ta_type == TA_TYPE_WIRELESS) {
			/* Decrease RX voltage (100mV) */
			pca9468->ta_vol = pca9468->ta_vol - WCRX_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"%s: PreCV VF Cont: rx_vol=%u",
					__func__, pca9468->ta_vol);
		} else {
			/* Decrease TA voltage (20mV) */
			pca9468->ta_vol = pca9468->ta_vol -
					  PCA9468_TA_VOL_STEP_PRE_CV *
					  pca9468->chg_mode;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"%s: PreCV VF Cont: ta_vol=%u",
					__func__, pca9468->ta_vol);
		}

		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
		break;

	case STS_MODE_LOOP_INACTIVE:
		/* Exit Pre CV mode */
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"%s: PreCV End: ta_vol=%u, ta_cur=%u",
				__func__, pca9468->ta_vol, pca9468->ta_cur);

		/* Need to implement notification to other driver */
		/* To do here */

		/* Go to CV mode */
		pca9468->timer_id = TIMER_CHECK_CVMODE;
		pca9468->timer_period = 0;
		break;

	case STS_MODE_VIN_UVLO:
		/* VIN UVLO - just notification , it works by hardware */
		vin_vol = pca9468_read_adc(pca9468, ADCCH_VIN);

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"%s: PreCV VIN_UVLO: ta_vol=%u, vin_vol=%u",
				__func__, pca9468->ta_cur, vin_vol);

		/* Check VIN after 1sec */
		pca9468->timer_id = TIMER_ENTER_CVMODE;
		pca9468->timer_period = 1000;
		break;

	default:
		break;
	}

	mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
			 msecs_to_jiffies(pca9468->timer_period));
error_exit:
	mutex_unlock(&pca9468->lock);
	pr_debug("%s: End, ret=%d\n", __func__, ret);
	return ret;
}

static int pca9468_check_eoc(struct pca9468_charger *pca9468)
{
	const int eoc_tolerance = 25000; /* 25mV under max float voltage */
	const int vlimit = PCA9468_COMP_VFLOAT_MAX - eoc_tolerance;
	int iin, vbat;

	iin = pca9468_read_adc(pca9468, ADCCH_IIN);
	if (iin < 0) {
		pr_err("%s: iin=%d\n", __func__, iin);
		return iin;
	}

	vbat = pca9468_read_adc(pca9468, ADCCH_VBAT);
	if (vbat < 0) {
		pr_err("%s: vbat=%d\n", __func__, vbat);
		return vbat;
	}

	pr_debug("%s: iin=%d, topoff=%u, vbat=%d vlimit=%d\n", __func__,
		 iin, pca9468->pdata->iin_topoff,
		 vbat, vlimit);

	return iin < pca9468->pdata->iin_topoff && vbat >= vlimit;
}

/* 2:1 Direct Charging CV MODE control */
static int pca9468_charge_cvmode(struct pca9468_charger *pca9468)
{
	int ret = 0;
	int cvmode;
	int vin_vol;

	pr_debug("%s: ======START=======\n", __func__);

	mutex_lock(&pca9468->lock);

	if (pca9468->charging_state != DC_STATE_CV_MODE)
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_CV_MODE);

	pca9468->charging_state = DC_STATE_CV_MODE;

	ret = pca9468_check_error(pca9468);
	if (ret != 0)
		goto error_exit;

	/*
	 * A change in vfloat and cc_max here is a normal tier transition, a
	 * change in iin  means that the thermal engine has changed cc_max.
	 */
	ret = pca9468_apply_new_limits(pca9468);
	if (ret < 0)
		goto error_exit;
	if (ret > 0)
		goto done;

	cvmode = pca9468_check_status(pca9468);
	if (cvmode < 0) {
		ret = cvmode;
		goto error_exit;
	}

	if (cvmode == STS_MODE_LOOP_INACTIVE) {
		ret = pca9468_check_eoc(pca9468);
		if (ret < 0)
			goto error_exit;
		if (ret)
			cvmode = STS_MODE_CHG_DONE;
	}

	switch(cvmode) {
	case STS_MODE_CHG_DONE: {
		const bool done_already = pca9468->charging_state ==
					  DC_STATE_CHARGING_DONE;

		if (!done_already)
			dev_info(pca9468->dev, "%s: charging_state=%u->%u\n",
				 __func__, pca9468->charging_state,
				 DC_STATE_CHARGING_DONE);


		/* Keep CV mode until driver send stop charging */
		pca9468->charging_state = DC_STATE_CHARGING_DONE;
		power_supply_changed(pca9468->mains);

		/* _cpm already came in */
		if (pca9468->charging_state == DC_STATE_NO_CHARGING) {
			pr_debug("%s: Already stop DC\n", __func__);
			break;
		}

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"%s: done_already=%d charge Done\n", __func__,
				done_already);

		pca9468->timer_id = TIMER_CHECK_CVMODE;
		pca9468->timer_period = PCA9468_CVMODE_CHECK_T;
	} break;

	case STS_MODE_CHG_LOOP:
	case STS_MODE_IIN_LOOP:
		/* Check the TA type */
		if (pca9468->ta_type == TA_TYPE_WIRELESS) {
			/* Decrease RX Voltage (100mV) */
			pca9468->ta_vol = pca9468->ta_vol -
						WCRX_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"%s: CV LOOP, Cont: rx_vol=%u",
					__func__, pca9468->ta_vol);

		/* Check TA current */
		} else if (pca9468->ta_cur > PCA9468_TA_MIN_CUR) {
			/* TA current is higher than (1.0A*chg_mode) */
			/* Decrease TA current (50mA) */
			pca9468->ta_cur = pca9468->ta_cur -
						PD_MSG_TA_CUR_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"%s: CV LOOP, Cont: ta_cur=%u",
					__func__, pca9468->ta_cur);
		} else {
			/* TA current is less than (1.0A*chg_mode) */
			/* Decrease TA Voltage (20mV) */
			pca9468->ta_vol = pca9468->ta_vol -
						PD_MSG_TA_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"%s: CV LOOP, Cont: ta_vol=%u",
					__func__, pca9468->ta_vol);
		}

		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
		break;

	case STS_MODE_VFLT_LOOP:
		/* Check the TA type */
		if (pca9468->ta_type == TA_TYPE_WIRELESS) {
			/* Decrease RX voltage */
			pca9468->ta_vol = pca9468->ta_vol -
						WCRX_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"%s: CV VFLOAT, Cont: rx_vol=%u",
					__func__, pca9468->ta_vol);
		} else {
			/* Decrease TA voltage */
			pca9468->ta_vol = pca9468->ta_vol -
						PD_MSG_TA_VOL_STEP;
			logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
					"%s: CV VFLOAT, Cont: ta_vol=%u",
					__func__, pca9468->ta_vol);
		}

		/* Send PD Message */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;
		break;

	case STS_MODE_LOOP_INACTIVE:
		pca9468->timer_id = TIMER_CHECK_CVMODE;
		pca9468->timer_period = PCA9468_CVMODE_CHECK_T;
		break;

	case STS_MODE_VIN_UVLO:
		/* VIN UVLO - just notification, it works by hardware */
		vin_vol = pca9468_read_adc(pca9468, ADCCH_VIN);
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"%s: CC VIN_UVLO: ta_cur=%u ta_vol=%u, vin_vol=%d",
				__func__, pca9468->ta_cur, pca9468->ta_vol,
				vin_vol);

		/* Check VIN after 1sec */
		pca9468->timer_id = TIMER_CHECK_CVMODE;
		pca9468->timer_period = 1000;
		break;

	default:
		break;
	}

done:
	pr_debug("%s: reschedule next id=%d period=%ld chg_state=%d\n",
		 __func__, pca9468->timer_id, pca9468->timer_period,
		pca9468->charging_state);

	mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
			 msecs_to_jiffies(pca9468->timer_period));
error_exit:
	mutex_unlock(&pca9468->lock);
	pr_debug("%s: End, ret=%d next\n", __func__, ret);
	return ret;
}

/*
 * Preset TA voltage and current for Direct Charging Mode using
 * the configured cc_max and fv_uv limits. Used only on start
 */
static int pca9468_preset_dcmode(struct pca9468_charger *pca9468)
{
	int vbat;
	int ret = 0;

	pr_debug("%s: ======START=======\n", __func__);
	pr_debug("%s: = charging_state=%u == \n", __func__,
		 pca9468->charging_state);

	/* gcpm set ->cc_max and ->fv_uv before starting */
	if (pca9468->cc_max < 0 || pca9468->fv_uv < 0) {
		pr_err("%s: cc_max=%d fv_uv=%d invalid\n", __func__,
		       pca9468->cc_max, pca9468->fv_uv);
		return -EINVAL;
	}

	if (pca9468->charging_state != DC_STATE_PRESET_DC)
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_PRESET_DC);

	pca9468->charging_state = DC_STATE_PRESET_DC;

	/* VBAT is over threshold but it might be "bouncy" due to transitory */
	vbat = pca9468_read_adc(pca9468, ADCCH_VBAT);
	if (vbat < 0) {
		ret = vbat;
		goto error;
	}

	/* v_float is set on start from GCPM */
	if (vbat > pca9468->fv_uv) {
		pr_err("%s: vbat adc=%d is higher than VFLOAT=%d\n", __func__,
			vbat, pca9468->fv_uv);
		ret = -EINVAL;
		goto error;
	}

	/* determined by ->cfg_iin and cc_max */
	pca9468->ta_max_cur = pca9468_get_iin_max(pca9468, pca9468->cc_max);
	pr_debug("%s: ta_max_cur=%u, iin_cfg=%u, pca9468->ta_type=%d\n",
		 __func__, pca9468->ta_max_cur, pca9468->pdata->iin_cfg,
		 pca9468->ta_type);

	/* Check the TA type and set the charging mode */
	if (pca9468->ta_type == TA_TYPE_WIRELESS) {
		/*
		 * Set the RX max voltage to enough high value to find RX
		 * maximum voltage initially
		 */
		pca9468->ta_max_vol = PCA9468_WCRX_MAX_VOL * pca9468->chg_mode;

		/* Get the RX max current/voltage(RX_MAX_CUR/VOL) */
		ret = pca9468_get_rx_max_power(pca9468);
		if (ret < 0) {
			pr_err("%s: no RX voltage to support 4:1 (%d)\n", __func__, ret);
			pca9468->chg_mode = CHG_NO_DC_MODE;
			goto error;
		}

		ret = pca9468_set_wireless_dc(pca9468, vbat);
		if (ret < 0) {
			pr_err("%s: set wired failed (%d)\n", __func__, ret);
			pca9468->chg_mode = CHG_NO_DC_MODE;
			goto error;
		}

		logbuffer_prlog(pca9468, LOGLEVEL_INFO,
				"Preset DC, rx_max_vol=%u, rx_max_cur=%u, rx_max_pwr=%lu, iin_cc=%u, chg_mode=%u",
				pca9468->ta_max_vol, pca9468->ta_max_cur, pca9468->ta_max_pwr,
				pca9468->iin_cc, pca9468->chg_mode);
	} else {
		const unsigned int ta_max_vol = PCA9468_TA_MAX_VOL * pca9468->chg_mode;

		/*
		 * Get the APDO max for 2:1 mode.
		 * Returns ->ta_max_vol, ->ta_max_cur, ->ta_max_pwr and
		 * ->ta_objpos for the given ta_max_vol and ta_max_cur.
		 */
		ret = pca9468_get_apdo_max_power(pca9468, ta_max_vol, PCA9468_TA_MAX_CUR);
		if (ret < 0) {
			pr_warn("%s: No APDO to support 2:1 for %d\n", __func__,
				PCA9468_TA_MAX_CUR);
			ret = pca9468_get_apdo_max_power(pca9468, ta_max_vol, 0);
		}

		if (ret < 0) {
			int ret1;

			pr_err("%s: No APDO to support 2:1\n", __func__);
			pca9468->chg_mode = CHG_NO_DC_MODE;

			if (!pca9468->dc_avail)
				pca9468->dc_avail =
					gvotable_election_get_handle(VOTABLE_DC_CHG_AVAIL);

			if (pca9468->dc_avail) {
				ret1 = gvotable_cast_int_vote(pca9468->dc_avail,
							      REASON_DC_DRV, 0, 1);
				if (ret1 < 0)
					dev_err(pca9468->dev,
						"Unable to cast vote for DC Chg avail (%d)\n",
						ret1);
			}
			goto error;
		}

		/*
		 * ->ta_max_cur is too high for startup, needs to target
		 * CC before hitting max current AND work to ta_max_cur
		 * from there.
		 */
		ret = pca9468_set_wired_dc(pca9468, vbat);
		if (ret < 0) {
			pr_err("%s: set wired failed (%d)\n", __func__, ret);
			pca9468->chg_mode = CHG_NO_DC_MODE;
			goto error;
		}

		logbuffer_prlog(pca9468, LOGLEVEL_INFO,
				"Preset DC, objpos=%d ta_max_vol=%u, ta_max_cur=%u, ta_max_pwr=%lu, iin_cc=%u, chg_mode=%u",
				pca9468->ta_objpos, pca9468->ta_max_vol, pca9468->ta_max_cur,
				pca9468->ta_max_pwr, pca9468->iin_cc, pca9468->chg_mode);

	}

error:
	pr_debug("%s: End, ret=%d\n", __func__, ret);
	return ret;
}

/* Preset direct charging configuration and start charging */
static int pca9468_preset_config(struct pca9468_charger *pca9468)
{
	int ret = 0;

	pr_debug("%s: ======START=======\n", __func__);

	mutex_lock(&pca9468->lock);

	dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			pca9468->charging_state, DC_STATE_PRESET_DC);

	pca9468->charging_state = DC_STATE_PRESET_DC;

	/* ->iin_cc and ->fv_uv are configured externally */
	ret = pca9468_set_input_current(pca9468, pca9468->pdata->iin_cfg);
	if (ret < 0)
		goto error;

	ret = pca9468_set_vfloat(pca9468, pca9468->fv_uv);
	if (ret < 0)
		goto error;

	/* Enable PCA9468 unless aready enabled */
	ret = pca9468_set_charging(pca9468, true);
	if (ret < 0)
		goto error;

	/* Clear previous iin adc */
	pca9468->prev_iin = 0;
	pca9468->prev_inc = INC_NONE;

	/* Go to CHECK_ACTIVE state after 150ms, 300ms for wireless */
	pca9468->timer_id = TIMER_CHECK_ACTIVE;
	if (pca9468->ta_type == TA_TYPE_WIRELESS)
		pca9468->timer_period = PCA9468_ENABLE_WLC_DELAY_T;
	else
		pca9468->timer_period = PCA9468_ENABLE_DELAY_T;
	mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
			   msecs_to_jiffies(pca9468->timer_period));
error:
	mutex_unlock(&pca9468->lock);
	pr_debug("%s: End, ret=%d\n", __func__, ret);
	return ret;
}

/*
 * Check the charging status at start before entering the adjust cc mode or
 * from pca9468_send_message() after a failure.
 */
static int pca9468_check_active_state(struct pca9468_charger *pca9468)
{
	int ret = 0;

	pr_debug("%s: ======START=======\n", __func__);
	pr_debug("%s: = charging_state=%u == \n", __func__,
		 pca9468->charging_state);

	mutex_lock(&pca9468->lock);

	if (pca9468->charging_state != DC_STATE_CHECK_ACTIVE)
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_CHECK_ACTIVE);

	pca9468->charging_state = DC_STATE_CHECK_ACTIVE;

	ret = pca9468_check_error(pca9468);
	if (ret == 0) {
		/* PCA9468 is active state */
		pca9468->retry_cnt = 0;
		pca9468->timer_id = TIMER_ADJUST_CCMODE;
		pca9468->timer_period = 0;
	} else if (ret == -EAGAIN) {

		/* try restarting only */
		if (pca9468->retry_cnt >= PCA9468_MAX_RETRY_CNT) {
			pr_err("%s: retry failed\n", __func__);
			ret = -EINVAL;
			goto exit_done;
		}

		/*
		 * Disable charging to retry enabling it later, return 0 here
		 * and the timer loop will figure out that there is something
		 * wrong and will retry.
		 */
		ret = pca9468_set_charging(pca9468, false);
		pr_err("%s: retry cnt=%d, (%d)\n", __func__,
		       pca9468->retry_cnt, ret);
		if (ret == 0) {
			pca9468->timer_id = TIMER_PRESET_DC;
			pca9468->timer_period = 0;
			pca9468->retry_cnt++;
		}
	}

exit_done:

	/* Implement error handler function if it is needed */
	if (ret < 0) {
		logbuffer_prlog(pca9468, LOGLEVEL_ERR,
				"%s: charging_state=%d, not active or error (%d)",
				__func__, pca9468->charging_state, ret);
		pca9468->timer_id = TIMER_ID_NONE;
		pca9468->timer_period = 0;
	}

	mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
			 msecs_to_jiffies(pca9468->timer_period));
	mutex_unlock(&pca9468->lock);
	return ret;
}

/* Enter direct charging algorithm */
static int pca9468_start_direct_charging(struct pca9468_charger *pca9468)
{
	struct p9468_chg_stats *chg_data = &pca9468->chg_data;
	unsigned int val;
	int ret;

	pr_debug("%s: =========START=========\n", __func__);
	mutex_lock(&pca9468->lock);

	/* Set OV_DELTA to 40% */
	val = OV_DELTA_40P << MASK2SHIFT(PCA9468_BIT_OV_DELTA);
	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_SAFETY_CTRL,
				 PCA9468_BIT_OV_DELTA, val);
	if (ret < 0)
		goto error_done;

	/* Set Switching Frequency */
	val = pca9468->pdata->fsw_cfg;
	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_START_CTRL,
				 PCA9468_BIT_FSW_CFG, val);
	if (ret < 0)
		goto error_done;

	/* Set NTC voltage threshold */
	val = pca9468->pdata->ntc_th / PCA9468_NTC_TH_STEP;
	ret = regmap_write(pca9468->regmap, PCA9468_REG_NTC_TH_1, (val & 0xFF));
	if (ret < 0)
		goto error_done;
	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_NTC_TH_2,
				 PCA9468_BIT_NTC_THRESHOLD9_8, (val >> 8));
	if (ret < 0)
		goto error_done;

	/* configure DC charging type for the requested index */
	ret = pca9468_set_ta_type(pca9468, pca9468->pps_index);
	pr_info("%s: Current ta_type=%d, chg_mode=%d\n", __func__,
		pca9468->ta_type, pca9468->chg_mode);
	if (ret < 0)
		goto error_done;

	/* wake lock */
	__pm_stay_awake(pca9468->monitor_wake_lock);

	/* Preset charging configuration and TA condition */
	ret = pca9468_preset_dcmode(pca9468);
	if (ret == 0) {
		/* Configure the TA  and start charging */
		pca9468->timer_id = TIMER_PDMSG_SEND;
		pca9468->timer_period = 0;

		mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
				 msecs_to_jiffies(pca9468->timer_period));
	}

error_done:
	pr_debug("%s: End, ret=%d\n", __func__, ret);

	p9468_chg_stats_update(chg_data, pca9468);
	mutex_unlock(&pca9468->lock);
	return ret;
}

/* Check Vbat minimum level to start direct charging */
static int pca9468_check_vbatmin(struct pca9468_charger *pca9468)
{
	int ret = 0, vbat;

	pr_debug("%s: =========START=========\n", __func__);

	mutex_lock(&pca9468->lock);

	if (pca9468->charging_state != DC_STATE_CHECK_VBAT)
		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_CHECK_VBAT);

	pca9468->charging_state = DC_STATE_CHECK_VBAT;

	vbat = pca9468_read_adc(pca9468, ADCCH_VBAT);
	if (vbat < 0) {
		ret = vbat;
		goto error;
	}

	/* wait for CPM to send in the params */
	if (pca9468->cc_max < 0 || pca9468->fv_uv < 0) {
		pr_debug("%s: not yet fv_uv=%d, cc_max=%d vbat=%d\n", __func__,
			pca9468->fv_uv, pca9468->cc_max, vbat);

		/* retry again after 1sec */
		pca9468->timer_id = TIMER_VBATMIN_CHECK;
		pca9468->timer_period = PCA9468_VBATMIN_CHECK_T;
		pca9468->retry_cnt += 1;
	} else {
		logbuffer_prlog(pca9468, LOGLEVEL_INFO,
				"%s: starts at fv_uv=%d, cc_max=%d vbat=%d (min=%d)",
				__func__, pca9468->fv_uv, pca9468->cc_max, vbat,
				PCA9468_DC_VBAT_MIN);

		pca9468->timer_id = TIMER_PRESET_DC;
		pca9468->timer_period = 0;
		pca9468->retry_cnt = 0; /* start charging */
	}

	/* timeout for VBATMIN or charging parameters */
	if (pca9468->retry_cnt > PCA9468_MAX_RETRY_CNT) {
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"%s: TIMEOUT fv_uv=%d, cc_max=%d vbat=%d limit=%d",
				__func__, pca9468->fv_uv, pca9468->cc_max, vbat,
				PCA9468_DC_VBAT_MIN);
		ret = -ETIMEDOUT;
	} else {
		mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
				 msecs_to_jiffies(pca9468->timer_period));
	}


error:
	mutex_unlock(&pca9468->lock);
	pr_debug("%s: End, ret=%d\n", __func__, ret);
	return ret;
}

static int pca9468_send_message(struct pca9468_charger *pca9468)
{
	int val, ret;
	const int timer_id = pca9468->timer_id;

	/* Go to the next state */
	mutex_lock(&pca9468->lock);

	pr_debug("%s: ====== START ======= \n", __func__);

	/* Adjust TA current and voltage step */
	if (pca9468->ta_type == TA_TYPE_WIRELESS) {
		/* RX voltage resolution is 100mV */
		val = pca9468->ta_vol / WCRX_VOL_STEP;
		pca9468->ta_vol = val * WCRX_VOL_STEP;

		/* Set RX voltage */
		pr_debug("%s: ta_type=%d, ta_vol=%d\n", __func__,
			 pca9468->ta_type, pca9468->ta_vol);
		ret = pca9468_send_rx_voltage(pca9468, WCRX_REQUEST_VOLTAGE);
	} else {
		/* PPS voltage resolution is 20mV */
		val = pca9468->ta_vol / PD_MSG_TA_VOL_STEP;
		pca9468->ta_vol = val * PD_MSG_TA_VOL_STEP;
		/* PPS current resolution is 50mA */
		val = pca9468->ta_cur / PD_MSG_TA_CUR_STEP;
		pca9468->ta_cur = val * PD_MSG_TA_CUR_STEP;
		/* PPS minimum current is 1000mA */
		if (pca9468->ta_cur < PCA9468_TA_MIN_CUR)
			pca9468->ta_cur = PCA9468_TA_MIN_CUR;

		pr_debug("%s: ta_type=%d, ta_vol=%d ta_cur=%d\n", __func__,
			 pca9468->ta_type, pca9468->ta_vol, pca9468->ta_cur);

		/* Send PD Message */
		ret = pca9468_send_pd_message(pca9468, PD_MSG_REQUEST_APDO);
	}

	switch (pca9468->charging_state) {
	case DC_STATE_PRESET_DC:
		pca9468->timer_id = TIMER_PRESET_CONFIG;
		break;
	case DC_STATE_ADJUST_CC:
		pca9468->timer_id = TIMER_ADJUST_CCMODE;
		break;
	case DC_STATE_CC_MODE:
		pca9468->timer_id = TIMER_CHECK_CCMODE;
		break;
	case DC_STATE_START_CV:
		pca9468->timer_id = TIMER_ENTER_CVMODE;
		break;
	case DC_STATE_CV_MODE:
		pca9468->timer_id = TIMER_CHECK_CVMODE;
		break;
	case DC_STATE_ADJUST_TAVOL:
		pca9468->timer_id = TIMER_ADJUST_TAVOL;
		break;
	case DC_STATE_ADJUST_TACUR:
		pca9468->timer_id = TIMER_ADJUST_TACUR;
		break;
	default:
		ret = -EINVAL;
		break;
	}

	if (ret < 0) {
		pr_err("%s: Error-send_pd_message to %d (%d)\n",
			__func__, pca9468->ta_type, ret);
		pca9468->timer_id = TIMER_CHECK_ACTIVE;
	}

	if (pca9468->ta_type == TA_TYPE_WIRELESS)
		pca9468->timer_period = PCA9468_PDMSG_WLC_WAIT_T;
	else
		pca9468->timer_period = PCA9468_PDMSG_WAIT_T;

	logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
			"%s: charging_state=%u timer_id:%d->%d ret=%d",
			__func__, pca9468->charging_state,
			timer_id, pca9468->timer_id, ret);

	mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
			 msecs_to_jiffies(pca9468->timer_period));

	pr_debug("%s: End: timer_id=%d timer_period=%lu\n", __func__,
		 pca9468->timer_id, pca9468->timer_period);

	mutex_unlock(&pca9468->lock);
	return ret;
}

/* delayed work function for charging timer */
static void pca9468_timer_work(struct work_struct *work)
{
	struct pca9468_charger *pca9468 =
		container_of(work, struct pca9468_charger, timer_work.work);
	unsigned int charging_state;
	int timer_id;
	int ret = 0;

	pr_debug("%s: ========= START =========\n", __func__);

	/* TODO: remove locks from the calls and run all of this locked */
	mutex_lock(&pca9468->lock);

	p9468_chg_stats_update(&pca9468->chg_data, pca9468);
	charging_state = pca9468->charging_state;
	timer_id = pca9468->timer_id;

	pr_debug("%s: timer id=%d, charging_state=%u\n", __func__,
		 pca9468->timer_id, charging_state);

	mutex_unlock(&pca9468->lock);

	switch (timer_id) {

	/* charging_state <- DC_STATE_CHECK_VBAT */
	case TIMER_VBATMIN_CHECK:
		ret = pca9468_check_vbatmin(pca9468);
		if (ret < 0)
			goto error;
		break;

	/* charging_state <- DC_STATE_PRESET_DC */
	case TIMER_PRESET_DC:
		ret = pca9468_start_direct_charging(pca9468);
		if (ret < 0)
			goto error;
		break;

	/*
	 * charging_state <- DC_STATE_PRESET_DC
	 *	preset configuration, start charging
	 */
	case TIMER_PRESET_CONFIG:
		ret = pca9468_preset_config(pca9468);
		if (ret < 0)
			goto error;
		break;

	/*
	 * charging_state <- DC_STATE_PRESET_DC
	 *	150 ms after preset_config
	 */
	case TIMER_CHECK_ACTIVE:
		ret = pca9468_check_active_state(pca9468);
		if (ret < 0)
			goto error;
		break;

	case TIMER_ADJUST_CCMODE:
		ret = pca9468_charge_adjust_ccmode(pca9468);
		if (ret < 0)
			goto error;
		break;

	case TIMER_CHECK_CCMODE:
		ret = pca9468_charge_ccmode(pca9468);
		if (ret < 0)
			goto error;
		break;

	case TIMER_ENTER_CVMODE:
		/* Enter Pre-CV mode */
		ret = pca9468_charge_start_cvmode(pca9468);
		if (ret < 0)
			goto error;
		break;

	case TIMER_CHECK_CVMODE:
		ret = pca9468_charge_cvmode(pca9468);
		if (ret < 0)
			goto error;
		break;

	case TIMER_PDMSG_SEND:
		ret = pca9468_send_message(pca9468);
		if (ret < 0)
			goto error;
		break;

	/* called from 2 contexts */
	case TIMER_ADJUST_TAVOL:
		mutex_lock(&pca9468->lock);

		if (pca9468->ta_type == TA_TYPE_WIRELESS)
			ret = pca9468_adjust_rx_voltage(pca9468);
		else
			ret = pca9468_adjust_ta_voltage(pca9468);
		if (ret < 0) {
			mutex_unlock(&pca9468->lock);
			goto error;
		}

		mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
				 msecs_to_jiffies(pca9468->timer_period));
		mutex_unlock(&pca9468->lock);
		break;

	/* called from 2 contexts */
	case TIMER_ADJUST_TACUR:
		mutex_lock(&pca9468->lock);
		ret = pca9468_adjust_ta_current(pca9468);
		if (ret < 0) {
			mutex_unlock(&pca9468->lock);
			goto error;
		}

		mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
				 msecs_to_jiffies(pca9468->timer_period));
		mutex_unlock(&pca9468->lock);
		break;

	case TIMER_ID_NONE:
		ret = pca9468_stop_charging(pca9468);
		if (ret < 0)
			goto error;
		break;

	default:
		break;
	}

	/* Check the charging state again */
	if (pca9468->charging_state == DC_STATE_NO_CHARGING) {
		cancel_delayed_work(&pca9468->timer_work);
		cancel_delayed_work(&pca9468->pps_work);
	}

	pr_debug("%s: timer_id=%d->%d, charging_state=%u->%u, period=%ld\n",
		 __func__, timer_id, pca9468->timer_id, charging_state,
		 pca9468->charging_state, pca9468->timer_period);

	return;

error:
	pr_debug("%s: ========= ERROR =========\n", __func__);
	logbuffer_prlog(pca9468, LOGLEVEL_ERR,
			"%s: timer_id=%d->%d, charging_state=%u->%u, period=%ld ret=%d",
			__func__, timer_id, pca9468->timer_id, charging_state,
			pca9468->charging_state, pca9468->timer_period, ret);

	pca9468_stop_charging(pca9468);
}

/* delayed work function for pps periodic timer */
static void pca9468_pps_request_work(struct work_struct *work)
{
	struct pca9468_charger *pca9468 = container_of(work,
					struct pca9468_charger, pps_work.work);
	int ret;

	pr_debug("%s: =========START=========\n", __func__);
	pr_debug("%s: = charging_state=%u == \n", __func__,
		 pca9468->charging_state);

	ret = pca9468_send_pd_message(pca9468, PD_MSG_REQUEST_APDO);
	if (ret < 0)
		pr_err("%s: Error-send_pd_message\n", __func__);

	/* TODO: do other background stuff */

	pr_debug("%s: ret=%d\n", __func__, ret);
}

static int pca9468_hw_ping(struct pca9468_charger *pca9468)
{
	unsigned int val = 0;
	int ret;

	/* Read Device info register to check the incomplete I2C operation */
	ret = regmap_read(pca9468->regmap, PCA9468_REG_DEVICE_INFO, &val);
	if ((ret < 0) || (val != PCA9468_DEVICE_ID))
		ret = regmap_read(pca9468->regmap, PCA9468_REG_DEVICE_INFO, &val);
	if ((ret < 0) || (val != PCA9468_DEVICE_ID)) {
		dev_err(pca9468->dev, "reading DEVICE_INFO failed, val=%#x ret=%d\n",
			val, ret);
		return -EINVAL;
	}

	return 0;
}

/* one and done in probe */
static int pca9468_hw_init(struct pca9468_charger *pca9468)
{
	unsigned int val;
	int ret;

	/* Set OV_DELTA to 40% */
	val = OV_DELTA_40P << MASK2SHIFT(PCA9468_BIT_OV_DELTA);
	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_SAFETY_CTRL,
				 PCA9468_BIT_OV_DELTA, val);
	if (ret < 0)
		return ret;

	/* Set Switching Frequency */
	val = pca9468->pdata->fsw_cfg << MASK2SHIFT(PCA9468_BIT_FSW_CFG);
	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_START_CTRL,
				 PCA9468_BIT_FSW_CFG, val);
	if (ret < 0)
		return ret;

	/* Enable Reverse Current Detection, Active mode High, Force standby */
	val = PCA9468_BIT_REV_IIN_DET | PCA9468_EN_ACTIVE_H |
	      PCA9468_STANDBY_FORCED;
	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_START_CTRL,
				 (PCA9468_BIT_REV_IIN_DET |
				  PCA9468_BIT_EN_CFG |
				  PCA9468_BIT_STANDBY_EN),
				 val);
	if (ret < 0)
		return ret;

	/* clear LIMIT_INCREMENT_EN */
	val = 0;
	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_IIN_CTRL,
				 PCA9468_BIT_LIMIT_INCREMENT_EN, val);
	if (ret < 0)
		return ret;

	/* Set the ADC channels, NTC is invalid if Bias is not enabled */
	val = PCA9468_BIT_CH6_EN |	/* DIETEMP ADC */
	      PCA9468_BIT_CH5_EN |	/* IIN ADC */
	      PCA9468_BIT_CH3_EN |	/* VBAT ADC */
	      PCA9468_BIT_CH2_EN |	/* VIN ADC */
	      PCA9468_BIT_CH1_EN;	/* VOUT ADC */

	ret = regmap_write(pca9468->regmap, PCA9468_REG_ADC_CFG, val);
	if (ret < 0)
		return ret;

	/* ADC Mode change */
	val = 0x5B;
	ret = regmap_write(pca9468->regmap, PCA9468_REG_ADC_ACCESS, val);
	if (ret < 0)
		return ret;
	val = 0x10;
	ret = regmap_write(pca9468->regmap, PCA9468_REG_ADC_MODE, val);
	if (ret < 0)
		return ret;
	val = 0x00;
	ret = regmap_write(pca9468->regmap, PCA9468_REG_ADC_ACCESS, val);
	if (ret < 0)
		return ret;

	/* Read ADC compensation gain */
	ret = regmap_read(pca9468->regmap, PCA9468_REG_ADC_ADJUST, &val);
	if (ret < 0)
		return ret;
	pca9468->adc_comp_gain = adc_gain[val >> MASK2SHIFT(PCA9468_BIT_ADC_GAIN)];

	/* input current - uA*/
	ret = pca9468_set_input_current(pca9468, pca9468->pdata->iin_cfg);
	if (ret < 0)
		return ret;

	/* v float voltage */
	ret = pca9468_set_vfloat(pca9468, pca9468->pdata->v_float);
	if (ret < 0)
		return ret;

	/* Spread Spectrum settings */
	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_ADC_CTRL,
				 PCA9468_BIT_SC_CLK_DITHER_RATE,
				 pca9468->pdata->sc_clk_dither_rate);
	if (ret < 0)
		return ret;
	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_NTC_TH_2,
				 PCA9468_SC_CLK_DITHER_LIMIT,
				 pca9468->pdata->sc_clk_dither_limit << 4);
	if (ret < 0)
		return ret;
	val = pca9468->pdata->sc_clk_dither_en ? PCA9468_BIT_SC_CLK_DITHER_EN : 0;
	ret = regmap_update_bits(pca9468->regmap, PCA9468_REG_TEMP_CTRL,
				 PCA9468_BIT_SC_CLK_DITHER_EN, val);
	if (ret < 0)
		return ret;

	return ret;
}

static irqreturn_t pca9468_interrupt_handler(int irq, void *data)
{
	struct pca9468_charger *pca9468 = data;
	/* INT1, INT1_MSK, INT1_STS, STS_A, B, C, D */
	u8 int1[REG_INT1_MAX], sts[REG_STS_MAX];
	u8 masked_int;	/* masked int */
	bool handled = false;
	int ret;

	/* Read INT1, INT1_MSK, INT1_STS */
	ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_INT1, int1, 3);
	if (ret < 0) {
		dev_warn(pca9468->dev, "reading INT1_X failed\n");
		return IRQ_NONE;
	}

	/* Read STS_A, B, C, D */
	ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_STS_A, sts, 4);
	if (ret < 0) {
		dev_warn(pca9468->dev, "reading STS_X failed\n");
		return IRQ_NONE;
	}

	pr_debug("%s: int1=0x%2x, int1_sts=0x%2x, sts_a=0x%2x\n", __func__,
			int1[REG_INT1], int1[REG_INT1_STS], sts[REG_STS_A]);

	/* Check Interrupt */
	masked_int = int1[REG_INT1] & !int1[REG_INT1_MSK];
	if (masked_int & PCA9468_BIT_V_OK_INT) {
		/* V_OK interrupt happened */
		mutex_lock(&pca9468->lock);
		pca9468->mains_online = !!(int1[REG_INT1_STS] &
					PCA9468_BIT_V_OK_STS);

		/* TODO: alex perform a clean shutdown */
		mutex_unlock(&pca9468->lock);
		power_supply_changed(pca9468->mains);
		handled = true;
	}

	if (masked_int & PCA9468_BIT_NTC_TEMP_INT) {
		/* NTC_TEMP interrupt happened */
		if (int1[REG_INT1_STS] & PCA9468_BIT_NTC_TEMP_STS) {
			/* above NTC_THRESHOLD */
			dev_err(pca9468->dev, "charging stopped due to NTC threshold voltage\n");
		}
		handled = true;
	}

	if (masked_int & PCA9468_BIT_CHG_PHASE_INT) {
		/* CHG_PHASE interrupt happened */
		if (int1[REG_INT1_STS] & PCA9468_BIT_CHG_PHASE_STS) {
			/* Any of loops is active*/
			if (sts[REG_STS_A] & PCA9468_BIT_VFLT_LOOP_STS)	{
				/* V_FLOAT loop is in regulation */
				pr_debug("%s: V_FLOAT loop interrupt\n",
					__func__);
				/* Disable CHG_PHASE_M */
				ret = regmap_update_bits(pca9468->regmap,
						PCA9468_REG_INT1_MSK,
						PCA9468_BIT_CHG_PHASE_M,
						PCA9468_BIT_CHG_PHASE_M);
				if (ret < 0) {
					handled = false;
					return handled;
				}

				/* Go to Pre CV Mode */
				pca9468->timer_id = TIMER_ENTER_CVMODE;
				pca9468->timer_period = 10;
				mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
					msecs_to_jiffies(pca9468->timer_period));

			} else if (sts[REG_STS_A] & PCA9468_BIT_IIN_LOOP_STS) {
				/* IIN loop or ICHG loop is in regulation */
				pr_debug("%s: IIN loop interrupt\n", __func__);
			} else if (sts[REG_STS_A] & PCA9468_BIT_CHG_LOOP_STS) {
				/* ICHG loop is in regulation */
				pr_debug("%s: ICHG loop interrupt\n", __func__);
			}
		}
		handled = true;
	}

	if (masked_int & PCA9468_BIT_CTRL_LIMIT_INT) {
		/* CTRL_LIMIT interrupt happened */
		if (int1[REG_INT1_STS] & PCA9468_BIT_CTRL_LIMIT_STS) {
			/* No Loop is active or OCP */
			if (sts[REG_STS_B] & PCA9468_BIT_OCP_FAST_STS) {
				/* Input fast over current */
				dev_err(pca9468->dev, "IIN > 50A instantaneously\n");
			}
			if (sts[REG_STS_B] & PCA9468_BIT_OCP_AVG_STS) {
				/* Input average over current */
				dev_err(pca9468->dev, "IIN > IIN_CFG*150percent\n");
			}
		}
		handled = true;
	}

	if (masked_int & PCA9468_BIT_TEMP_REG_INT) {
		/* TEMP_REG interrupt happened */
		if (int1[REG_INT1_STS] & PCA9468_BIT_TEMP_REG_STS) {
			/* Device is in temperature regulation */
			dev_err(pca9468->dev, "Device is in temperature regulation\n");
		}
		handled = true;
	}

	if (masked_int & PCA9468_BIT_ADC_DONE_INT) {
		/* ADC complete interrupt happened */
		dev_dbg(pca9468->dev, "ADC has been completed\n");
		handled = true;
	}

	if (masked_int & PCA9468_BIT_TIMER_INT) {
		/* Timer falut interrupt happened */
		if (int1[REG_INT1_STS] & PCA9468_BIT_TIMER_STS) {
			if (sts[REG_STS_B] & PCA9468_BIT_CHARGE_TIMER_STS) {
				/* Charger timer is expired */
				dev_err(pca9468->dev, "Charger timer is expired\n");
			}
			if (sts[REG_STS_B] & PCA9468_BIT_WATCHDOG_TIMER_STS) {
				/* Watchdog timer is expired */
				dev_err(pca9468->dev, "Watchdog timer is expired\n");
			}
		}
		handled = true;
	}

	return handled ? IRQ_HANDLED : IRQ_NONE;
}

static int pca9468_irq_init(struct pca9468_charger *pca9468,
			    struct i2c_client *client)
{
	const struct pca9468_platform_data *pdata = pca9468->pdata;
	int ret, msk, irq;

	irq = gpio_to_irq(pdata->irq_gpio);

	ret = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name);
	if (ret < 0)
		goto fail;

	ret = request_threaded_irq(irq, NULL, pca9468_interrupt_handler,
				   IRQF_TRIGGER_LOW | IRQF_ONESHOT,
				   client->name, pca9468);
	if (ret < 0)
		goto fail_gpio;

	/* disable all interrupts by default. */
	msk = PCA9468_BIT_V_OK_M |
	      PCA9468_BIT_NTC_TEMP_M |
	      PCA9468_BIT_CHG_PHASE_M |
	      PCA9468_BIT_RESERVED_M |
	      PCA9468_BIT_CTRL_LIMIT_M |
	      PCA9468_BIT_TEMP_REG_M |
	      PCA9468_BIT_ADC_DONE_M |
	      PCA9468_BIT_TIMER_M;
	ret = regmap_write(pca9468->regmap, PCA9468_REG_INT1_MSK, msk);
	if (ret < 0)
		goto fail_write;

	client->irq = irq;
	return 0;

fail_write:
	free_irq(irq, pca9468);
fail_gpio:
	gpio_free(pdata->irq_gpio);
fail:
	client->irq = 0;
	return ret;
}

/* Returns the input current limit programmed into the charger in uA. */
int pca9468_input_current_limit(struct pca9468_charger *pca9468)
{
	int ret, intval;
	unsigned int val;

	if (!pca9468->mains_online)
		return -ENODATA;

	ret = regmap_read(pca9468->regmap, PCA9468_REG_IIN_CTRL, &val);
	if (ret < 0)
		return ret;

	intval = (val & PCA9468_BIT_IIN_CFG) * 100000;

	if (intval < 500000)
		intval = 500000;

	return intval;
}

/* Returns the constant charge current requested from GCPM */
static int get_const_charge_current(struct pca9468_charger *pca9468)
{
	/* Charging current cannot be controlled directly */
	return pca9468->cc_max;
}

/* Return the constant charge voltage programmed into the charger in uV. */
static int pca9468_const_charge_voltage(struct pca9468_charger *pca9468)
{
	unsigned int val;
	int ret;

	if (!pca9468->mains_online)
		return -ENODATA;

	ret = regmap_read(pca9468->regmap, PCA9468_REG_V_FLOAT, &val);
	if (ret < 0)
		return ret;

	return (val * 5 + 3725) * 1000;
}

#define get_boot_sec() div_u64(ktime_to_ns(ktime_get_boottime()), NSEC_PER_SEC)

/* index is the PPS source to use */
static int pca9468_set_charging_enabled(struct pca9468_charger *pca9468, int index)
{
	if (index < 0 || index >= PPS_INDEX_MAX)
		return -EINVAL;

	mutex_lock(&pca9468->lock);

	/* Done is detected in CV when iin goes UNDER topoff. */
	if (pca9468->charging_state == DC_STATE_CHARGING_DONE)
		index = 0;

	if (index == 0) {

		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"%s: stop pps_idx=%d->%d charging_state=%d timer_id=%d",
				__func__, pca9468->pps_index, index,
				pca9468->charging_state,
				pca9468->timer_id);

		/* this is the same as stop charging */
		pca9468->pps_index = 0;

		cancel_delayed_work(&pca9468->timer_work);
		cancel_delayed_work(&pca9468->pps_work);

		/* will call pca9468_stop_charging() in timer_work() */
		pca9468->timer_id = TIMER_ID_NONE;
		pca9468->timer_period = 0;
		mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
				 msecs_to_jiffies(pca9468->timer_period));
	} else if (pca9468->charging_state == DC_STATE_NO_CHARGING) {
		logbuffer_prlog(pca9468, LOGLEVEL_DEBUG,
				"%s: start pps_idx=%d->%d charging_state=%d timer_id=%d",
				__func__, pca9468->pps_index, index,
				pca9468->charging_state,
				pca9468->timer_id);

		/* Start Direct Charging on Index */
		pca9468->dc_start_time = get_boot_sec();
		p9468_chg_stats_init(&pca9468->chg_data);
		pca9468->irdrop_comp_ok = false;
		pca9468->pps_index = index;

		dev_info(pca9468->dev, "%s: charging_state=%u->%u\n", __func__,
			 pca9468->charging_state, DC_STATE_CHECK_VBAT);

		/* PD is already in PE_SNK_STATE */
		pca9468->charging_state = DC_STATE_CHECK_VBAT;
		pca9468->timer_id = TIMER_VBATMIN_CHECK;
		pca9468->timer_period = 0;
		mod_delayed_work(pca9468->dc_wq, &pca9468->timer_work,
				 msecs_to_jiffies(pca9468->timer_period));

		/* Set the initial charging step */
		power_supply_changed(pca9468->mains);
	}

	mutex_unlock(&pca9468->lock);

	return 0;
}

static int pca9468_mains_set_property(struct power_supply *psy,
				      enum power_supply_property prop,
				      const union power_supply_propval *val)
{
	struct pca9468_charger *pca9468 = power_supply_get_drvdata(psy);
	int ret = 0;

	pr_debug("%s: =========START=========\n", __func__);
	pr_debug("%s: prop=%d, val=%d\n", __func__, prop, val->intval);
	if (!pca9468->init_done)
		return -EAGAIN;

	switch (prop) {

	case POWER_SUPPLY_PROP_ONLINE:
		if (val->intval == 0) {
			ret = pca9468_stop_charging(pca9468);
			if (ret < 0)
				pr_err("%s: cannot stop charging (%d)\n",
				       __func__, ret);

			pca9468->mains_online = false;

			/* Reset DC Chg un-avail on disconnect */
			if (!pca9468->dc_avail)
				pca9468->dc_avail =
				gvotable_election_get_handle(VOTABLE_DC_CHG_AVAIL);

			if (pca9468->dc_avail) {
				ret = gvotable_cast_int_vote(pca9468->dc_avail,
							     REASON_DC_DRV, 1, 1);
				if (ret < 0)
					dev_err(pca9468->dev,
						"Unable to cast vote for DC Chg avail (%d)\n",
						ret);
			}
		} else if (pca9468->mains_online == false) {
			pca9468->mains_online = true;
		}

		break;

	/* TODO: locking is wrong */
	case GBMS_PROP_CHARGING_ENABLED:
		ret = pca9468_set_charging_enabled(pca9468, val->intval);
		break;

	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
		ret = pca9468_set_new_vfloat(pca9468, val->intval);
		break;

	/*
	 * pcaA9468 cannot control charging current directly so need to control
	 * current on TA side resolving cc_max for TA_VOL*TA_CUT on vbat.
	 * NOTE: iin should be equivalent to iin = cc_max /2
	 */
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
		ret = pca9468_set_new_cc_max(pca9468, val->intval);
		break;

	/* CURRENT MAX, same as IIN is really only set by the algo */
	case POWER_SUPPLY_PROP_CURRENT_MAX:
		pr_debug("%s: set iin %d, ignore\n", __func__, val->intval);
		break;

	/* allow direct setting, not used */
	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
		mutex_lock(&pca9468->lock);
		ret = pca9468_set_new_iin(pca9468, val->intval);
		mutex_unlock(&pca9468->lock);
		break;

	case GBMS_PROP_CHARGE_DISABLE:
		break;

	default:
		ret = -EINVAL;
		break;
	}

	pr_debug("%s: End, ret=%d\n", __func__, ret);
	return ret;
}

static int pca9468_mains_get_property(struct power_supply *psy,
				     enum power_supply_property prop,
				     union power_supply_propval *val)
{
	struct pca9468_charger *pca9468 = power_supply_get_drvdata(psy);
	union gbms_charger_state chg_state;
	int intval, rc, ret = 0;

	if (!pca9468->init_done)
		return -EAGAIN;

	switch (prop) {
	case POWER_SUPPLY_PROP_ONLINE:
		val->intval = pca9468->mains_online;
		break;
	case POWER_SUPPLY_PROP_PRESENT:
		val->intval = pca9468_is_present(pca9468);
		if (val->intval < 0)
			val->intval = 0;
		break;

	case GBMS_PROP_CHARGE_DISABLE:
		ret = pca9468_get_charging_enabled(pca9468);
		if (ret < 0)
			return ret;
		val->intval = !ret;
		break;

	case GBMS_PROP_CHARGING_ENABLED:
		ret = pca9468_get_charging_enabled(pca9468);
		if (ret < 0)
			return ret;
		val->intval = ret;
		break;

	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
		ret = pca9468_const_charge_voltage(pca9468);
		if (ret < 0)
			return ret;
		val->intval = ret;
		break;

	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
		ret = get_const_charge_current(pca9468);
		if (ret < 0)
			return ret;
		val->intval = ret;
		break;

	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
		ret = pca9468_input_current_limit(pca9468);
		if (ret < 0)
			return ret;
		val->intval = ret;
		break;

	case POWER_SUPPLY_PROP_CURRENT_NOW:
		/* return the output current - uA unit */
		rc = pca9468_get_iin(pca9468, &val->intval);
		if (rc < 0)
			dev_err(pca9468->dev, "Invalid IIN ADC (%d)\n", rc);
		break;

	case GBMS_PROP_CHARGE_CHARGER_STATE:
		ret = pca9468_get_chg_chgr_state(pca9468, &chg_state);
		if (ret < 0)
			return ret;
		if (pca9468->irdrop_comp_ok)
			chg_state.f.flags &= ~GBMS_CS_FLAG_NOCOMP;
		gbms_propval_int64val(val) = chg_state.v;
		break;

	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
		intval = pca9468_read_adc(pca9468, ADCCH_VOUT);
		if (intval < 0)
			return intval;
		val->intval = intval;
		break;

	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		intval = pca9468_read_adc(pca9468, ADCCH_VBAT);
		if (intval < 0)
			return intval;
		val->intval = intval;
		break;

	/* TODO: read NTC temperature? */
	case POWER_SUPPLY_PROP_TEMP:
		val->intval = pca9468_read_adc(pca9468, ADCCH_DIETEMP);
		break;

	case POWER_SUPPLY_PROP_CHARGE_TYPE:
		val->intval = pca9468_get_charge_type(pca9468);
		break;

	case POWER_SUPPLY_PROP_STATUS:
		val->intval = pca9468_get_status(pca9468);
		break;

	case POWER_SUPPLY_PROP_CURRENT_MAX:
		ret = pca9468_input_current_limit(pca9468);
		if (ret < 0)
			return ret;
		val->intval = ret;
		break;

	default:
		return -EINVAL;
	}

	return 0;
}

/*
 * GBMS not visible
 * POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
 * POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
 * POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
 * POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
 */
static enum power_supply_property pca9468_mains_properties[] = {
	POWER_SUPPLY_PROP_PRESENT,
	POWER_SUPPLY_PROP_ONLINE,
	POWER_SUPPLY_PROP_CHARGE_TYPE,
	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
	POWER_SUPPLY_PROP_TEMP,
	/* same as POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT */
	POWER_SUPPLY_PROP_CURRENT_MAX,
	POWER_SUPPLY_PROP_CURRENT_NOW,
	POWER_SUPPLY_PROP_VOLTAGE_MAX,
	POWER_SUPPLY_PROP_VOLTAGE_NOW,
	POWER_SUPPLY_PROP_STATUS,
};

static int pca9468_mains_is_writeable(struct power_supply *psy,
				      enum power_supply_property psp)
{
	switch (psp) {
	case POWER_SUPPLY_PROP_ONLINE:
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
	case POWER_SUPPLY_PROP_CURRENT_MAX:
	case GBMS_PROP_CHARGE_DISABLE:
		return 1;
	default:
		break;
	}

	return 0;
}

static bool pca9468_is_reg(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case PCA9468_REG_DEVICE_INFO ... PCA9468_REG_STS_ADC_9:
	case PCA9468_REG_IIN_CTRL ... PCA9468_REG_NTC_TH_2:
	case PCA9468_REG_ADC_ACCESS:
	case PCA9468_REG_ADC_ADJUST:
	case PCA9468_REG_ADC_IMPROVE:
	case PCA9468_REG_ADC_MODE:
	case 0x40 ... 0x4f: /* debug */
		return true;
	default:
		break;
	}

	return false;
}

static struct regmap_config pca9468_regmap = {
	.name		= "pca9468-mains",
	.reg_bits	= 8,
	.val_bits	= 8,
	.max_register	= PCA9468_MAX_REGISTER,
	.readable_reg = pca9468_is_reg,
	.volatile_reg = pca9468_is_reg,
};

static struct power_supply_desc pca9468_mains_desc = {
	.name		= "pca9468-mains",
	/* b/179246019 will not look online to Android */
	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
	.get_property	= pca9468_mains_get_property,
	.set_property 	= pca9468_mains_set_property,
	.properties	= pca9468_mains_properties,
	.property_is_writeable = pca9468_mains_is_writeable,
	.num_properties	= ARRAY_SIZE(pca9468_mains_properties),
};

#if defined(CONFIG_OF)
static int of_pca9468_dt(struct device *dev,
			 struct pca9468_platform_data *pdata)
{
	struct device_node *np_pca9468 = dev->of_node;
	int ret;
	if(!np_pca9468)
		return -EINVAL;

	/* irq gpio */
	pdata->irq_gpio = of_get_named_gpio(np_pca9468, "pca9468,irq-gpio", 0);
	pr_info("%s: irq-gpio: %d \n", __func__, pdata->irq_gpio);

	/* input current limit */
	ret = of_property_read_u32(np_pca9468, "pca9468,input-current-limit",
				   &pdata->iin_cfg_max);
	if (ret) {
		pr_warn("%s: pca9468,input-current-limit is Empty\n", __func__);
		pdata->iin_cfg_max = PCA9468_IIN_CFG_DFT;
	}
	pdata->iin_cfg = pdata->iin_cfg_max;
	pr_info("%s: pca9468,iin_cfg is %u\n", __func__, pdata->iin_cfg);

	/* charging float voltage */
	ret = of_property_read_u32(np_pca9468, "pca9468,float-voltage",
				   &pdata->v_float_dt);
	if (ret) {
		pr_warn("%s: pca9468,float-voltage is Empty\n", __func__);
		pdata->v_float_dt = PCA9468_VFLOAT_DFT;
	}
	pdata->v_float = pdata->v_float_dt;
	pr_info("%s: pca9468,v_float is %u\n", __func__, pdata->v_float);

	/* input topoff current */
	ret = of_property_read_u32(np_pca9468, "pca9468,input-itopoff",
				   &pdata->iin_topoff);
	if (ret) {
		pr_warn("%s: pca9468,input-itopoff is Empty\n", __func__);
		pdata->iin_topoff = PCA9468_IIN_DONE_DFT;
	}
	pr_info("%s: pca9468,iin_topoff is %u\n", __func__, pdata->iin_topoff);

	/* switching frequency */
	ret = of_property_read_u32(np_pca9468, "pca9468,switching-frequency",
				   &pdata->fsw_cfg);
	if (ret) {
		pr_warn("%s: pca9468,switching frequency is Empty\n", __func__);
		pdata->fsw_cfg = PCA9468_FSW_CFG_DFT;
	}
	pr_info("%s: pca9468,fsw_cfg is %u\n", __func__, pdata->fsw_cfg);

	/* NTC threshold voltage */
	ret = of_property_read_u32(np_pca9468, "pca9468,ntc-threshold",
				   &pdata->ntc_th);
	if (ret) {
		pr_warn("%s: pca9468,ntc threshold voltage is Empty\n",
			__func__);
		pdata->ntc_th = PCA9468_NTC_TH_DFT;
	}
	pr_info("%s: pca9468,ntc_th is %u\n", __func__, pdata->ntc_th);

	/* iin offsets */
	ret = of_property_read_u32(np_pca9468, "pca9468,iin-max-offset",
				   &pdata->iin_max_offset);
	if (ret)
		pdata->iin_max_offset = PCA9468_IIN_MAX_OFFSET;
	pr_info("%s: pca9468,iin_max_offset is %u\n", __func__, pdata->iin_max_offset);

	ret = of_property_read_u32(np_pca9468, "pca9468,iin-cc_comp-offset",
				   &pdata->iin_cc_comp_offset);
	if (ret)
		pdata->iin_cc_comp_offset = PCA9468_IIN_CC_COMP_OFFSET;
	pr_info("%s: pca9468,iin_cc_comp_offset is %u\n", __func__, pdata->iin_cc_comp_offset);

	/* irdrop limits */
	pdata->irdrop_limit_cnt =
	    of_property_count_elems_of_size(np_pca9468, "google,irdrop-limits", sizeof(u32));
	if (pdata->irdrop_limit_cnt < PCA9468_IRDROP_LIMIT_CNT) {
		pr_info("%s: google,irdrop-limits size get failed, use default irdrop limits %d\n",
			__func__, pdata->irdrop_limit_cnt);
		ret = -EINVAL;
	} else {
		ret = of_property_read_u32_array(np_pca9468, "google,irdrop-limits",
						 (u32 *)pdata->irdrop_limits,
						 PCA9468_IRDROP_LIMIT_CNT);
		if (ret)
			pr_info("%s: google,irdrop-limits get failed, use default irdrop limits",
				__func__);
	}
	if (ret) {
		pdata->irdrop_limits[0] = PCA9468_IRDROP_LIMIT_TIER1;
		pdata->irdrop_limits[1] = PCA9468_IRDROP_LIMIT_TIER2;
		pdata->irdrop_limits[2] = PCA9468_IRDROP_LIMIT_TIER3;
	}

	/* Spread Spectrum settings */
	ret = of_property_read_u32(np_pca9468, "pca9468,sc-clk-dither-rate",
				   &pdata->sc_clk_dither_rate);
	if (ret)
		pdata->sc_clk_dither_rate = PCA9468_SC_CLK_DITHER_RATE_DEF;
	else
		pr_info("%s: pca9468,sc-clk-dither-rate is %u\n", __func__,
			pdata->sc_clk_dither_rate);
	ret = of_property_read_u32(np_pca9468, "pca9468,sc-clk-dither-limit",
				   &pdata->sc_clk_dither_limit);
	if (ret)
		pdata->sc_clk_dither_limit = PCA9468_SC_CLK_DITHER_LIMIT_DEF;
	else
		pr_info("%s: pca9468,sc-clk-dither-limit is %u\n", __func__,
			pdata->sc_clk_dither_limit);
	pdata->sc_clk_dither_en = of_property_read_bool(np_pca9468, "pca9468,spread-spectrum");
	pr_info("%s: pca9468,spread-spectrum is %u\n", __func__, pdata->sc_clk_dither_en);

#ifdef CONFIG_THERMAL
	/* USBC thermal zone */
	ret = of_property_read_string(np_pca9468, "google,usb-port-tz-name",
				      &pdata->usb_tz_name);
	if (ret) {
		pr_info("%s: google,usb-port-tz-name is Empty\n", __func__);
		pdata->usb_tz_name = NULL;
	} else {
		pr_info("%s: google,usb-port-tz-name is %s\n", __func__,
			pdata->usb_tz_name);
	}
#endif

	return 0;
}
#else
static int of_pca9468_dt(struct device *dev,
			 struct pca9468_platform_data *pdata)
{
	return 0;
}
#endif /* CONFIG_OF */

#ifdef CONFIG_THERMAL
static int pca9468_usb_tz_read_temp(struct thermal_zone_device *tzd, int *temp)
{
	struct pca9468_charger *pca9468 = tzd->devdata;

	if (!pca9468)
		return -ENODEV;
	*temp = pca9468_read_adc(pca9468, ADCCH_NTC);

	return 0;
}

static struct thermal_zone_device_ops pca9468_usb_tzd_ops = {
	.get_temp = pca9468_usb_tz_read_temp,
};
#endif

static int read_reg(void *data, u64 *val)
{
	struct pca9468_charger *chip = data;
	int rc;
	unsigned int temp;

	rc = regmap_read(chip->regmap, chip->debug_address, &temp);
	if (rc) {
		pr_err("Couldn't read reg %x rc = %d\n",
			chip->debug_address, rc);
		return -EAGAIN;
	}
	*val = temp;
	return 0;
}

static int write_reg(void *data, u64 val)
{
	struct pca9468_charger *chip = data;
	int rc;
	u8 temp;

	temp = (u8) val;
	rc = regmap_write(chip->regmap, chip->debug_address, temp);
	if (rc) {
		pr_err("Couldn't write 0x%02x to 0x%02x rc = %d\n",
			temp, chip->debug_address, rc);
		return -EAGAIN;
	}
	return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(register_debug_ops, read_reg, write_reg, "0x%02llx\n");

static int debug_apply_offsets(void *data, u64 val)
{
	struct pca9468_charger *chip = data;
	int ret;

	ret = pca9468_set_new_cc_max(chip, chip->cc_max);
	pr_info("Apply offsets iin_max_o=%d iin_cc_comp_o=%d ret=%d\n",
		chip->pdata->iin_max_offset, chip->pdata->iin_cc_comp_offset,
		ret);

	return ret;
}
DEFINE_SIMPLE_ATTRIBUTE(apply_offsets_debug_ops, NULL, debug_apply_offsets, "0x%02llx\n");


static int debug_adc_chan_get(void *data, u64 *val)
{
	struct pca9468_charger *pca9468 = data;

	*val = pca9468_read_adc(data, pca9468->debug_adc_channel);
	return 0;
}

static int debug_adc_chan_set(void *data, u64 val)
{
	struct pca9468_charger *pca9468 = data;

	if (val < ADCCH_VOUT || val >= ADCCH_MAX)
		return -EINVAL;
	pca9468->debug_adc_channel = val;
	return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(debug_adc_chan_ops, debug_adc_chan_get,
			debug_adc_chan_set, "%llu\n");


static int debug_pps_index_get(void *data, u64 *val)
{
	struct pca9468_charger *pca9468 = data;

	*val = pca9468->pps_index;
	return 0;
}

static int debug_pps_index_set(void *data, u64 val)
{
	struct pca9468_charger *pca9468 = data;

	return pca9468_set_charging_enabled(pca9468, (int)val);
}

DEFINE_SIMPLE_ATTRIBUTE(debug_pps_index_ops, debug_pps_index_get,
			debug_pps_index_set, "%llu\n");

static ssize_t show_sts_ab(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct pca9468_charger *pca9468 = dev_get_drvdata(dev);
	u8 tmp[2];
	int ret;

	ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_STS_A, &tmp, sizeof(tmp));
	if (ret < 0)
		return ret;

	return scnprintf(buf, PAGE_SIZE, "%02x%02x\n", tmp[0], tmp[1]);
}

static DEVICE_ATTR(sts_ab, 0444, show_sts_ab, NULL);


static ssize_t p9468_show_chg_stats(struct device *dev, struct device_attribute *attr,
				    char *buff)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct pca9468_charger *pca9468 = i2c_get_clientdata(client);
	struct p9468_chg_stats *chg_data = &pca9468->chg_data;
	const int max_size = PAGE_SIZE;
	int len = -ENODATA;

	mutex_lock(&pca9468->lock);

	if (!p9468_chg_stats_valid(chg_data))
		goto exit_done;

	len = scnprintf(buff, max_size,
			"D:%#x,%#x %#x,%#x,%#x,%#x,%#x\n",
			chg_data->adapter_capabilities[0],
			chg_data->adapter_capabilities[1],
			chg_data->receiver_state[0],
			chg_data->receiver_state[1],
			chg_data->receiver_state[2],
			chg_data->receiver_state[3],
			chg_data->receiver_state[4]);
	len += scnprintf(&buff[len], max_size - len,
			"N: ovc=%d,ovc_ibatt=%d,ovc_delta=%d rcp=%d,stby=%d\n",
			chg_data->ovc_count, chg_data->ovc_max_ibatt, chg_data->ovc_max_delta,
			chg_data->rcp_count,
			chg_data->stby_count);
	len += scnprintf(&buff[len], max_size - len,
			"C: nc=%d,pre=%d,ca=%d,cc=%d,cv=%d,adj=%d\n",
			chg_data->nc_count,
			chg_data->pre_count,
			chg_data->ca_count,
			chg_data->cc_count,
			chg_data->cv_count,
			chg_data->adj_count);

exit_done:
	mutex_unlock(&pca9468->lock);
	return len;
}

static ssize_t p9468_set_chg_stats(struct device *dev, struct device_attribute *attr,
				   const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct pca9468_charger *pca9468 = i2c_get_clientdata(client);

	mutex_lock(&pca9468->lock);
	p9468_chg_stats_init(&pca9468->chg_data);
	mutex_unlock(&pca9468->lock);

	return count;
}

static DEVICE_ATTR(chg_stats, 0644, p9468_show_chg_stats, p9468_set_chg_stats);

static ssize_t show_dump_reg(struct device *dev, struct device_attribute *attr,
			     char *buf)
{
	struct pca9468_charger *pca9468 = dev_get_drvdata(dev);
	u8 tmp[PCA9468_MAX_REGISTER + 1];
	int ret, i;
	int len = 0;

	ret = regmap_bulk_read(pca9468->regmap, PCA9468_REG_DEVICE_INFO, &tmp,
			       PCA9468_MAX_REGISTER + 1);
	if (ret < 0)
		return ret;

	for (i = 0; i <= PCA9468_MAX_REGISTER; i++)
		len += scnprintf(&buf[len], PAGE_SIZE - len, "%02x: %02x\n", i, tmp[i]);

	return len;
}

static DEVICE_ATTR(registers_dump, 0444, show_dump_reg, NULL);

static int pca9468_create_fs_entries(struct pca9468_charger *chip)
{

	device_create_file(chip->dev, &dev_attr_sts_ab);
	device_create_file(chip->dev, &dev_attr_chg_stats);
	device_create_file(chip->dev, &dev_attr_registers_dump);

	chip->debug_root = debugfs_create_dir("charger-pca9468", NULL);
	if (IS_ERR_OR_NULL(chip->debug_root)) {
		dev_err(chip->dev, "Couldn't create debug dir\n");
		return -ENOENT;
	}

	debugfs_create_bool("wlc_rampout_iin", 0644, chip->debug_root,
			     &chip->wlc_ramp_out_iin);
	debugfs_create_u32("wlc_rampout_delay", 0644, chip->debug_root,
			   &chip->wlc_ramp_out_delay);
	debugfs_create_u32("wlc_rampout_vout_target", 0644, chip->debug_root,
			   &chip->wlc_ramp_out_vout_target);


	debugfs_create_u32("debug_level", 0644, chip->debug_root,
			   &debug_printk_prlog);
	debugfs_create_u32("no_logbuffer", 0644, chip->debug_root,
			   &debug_no_logbuffer);

	debugfs_create_file("data", 0644, chip->debug_root, chip, &register_debug_ops);
	debugfs_create_x32("address", 0644, chip->debug_root, &chip->debug_address);

	debugfs_create_u32("iin_max_offset", 0644, chip->debug_root,
			   &chip->pdata->iin_max_offset);
	debugfs_create_u32("iin_cc_comp_offset", 0644, chip->debug_root,
			   &chip->pdata->iin_cc_comp_offset);
	debugfs_create_file("apply_offsets", 0644, chip->debug_root, chip,
			    &apply_offsets_debug_ops);

	chip->debug_adc_channel = ADCCH_VOUT;
	debugfs_create_file("adc_chan", 0644, chip->debug_root, chip,
			    &debug_adc_chan_ops);
	debugfs_create_file("pps_index", 0644, chip->debug_root, chip,
			    &debug_pps_index_ops);
	debugfs_create_bool("irdrop_comp", 0644, chip->debug_root,
			    &chip->irdrop_comp_ok);

	return 0;
}


static int pca9468_probe(struct i2c_client *client,
			 const struct i2c_device_id *id)
{
	static char *battery[] = { "pca9468-battery" };
	struct power_supply_config mains_cfg = {};
	struct pca9468_platform_data *pdata;
	struct pca9468_charger *pca9468_chg;
	struct device *dev = &client->dev;
	const char *psy_name = NULL;
	int ret;

	pr_debug("%s: =========START=========\n", __func__);

	pca9468_chg = devm_kzalloc(dev, sizeof(*pca9468_chg), GFP_KERNEL);
	if (!pca9468_chg)
		return -ENOMEM;

#if defined(CONFIG_OF)
	if (client->dev.of_node) {
		pdata = devm_kzalloc(&client->dev,
				     sizeof(struct pca9468_platform_data),
				     GFP_KERNEL);
		if (!pdata) {
			dev_err(&client->dev, "Failed to allocate memory \n");
			return -ENOMEM;
		}

		ret = of_pca9468_dt(&client->dev, pdata);
		if (ret < 0){
			dev_err(&client->dev, "Failed to get device of_node \n");
			return -ENOMEM;
		}

		client->dev.platform_data = pdata;
	} else {
		pdata = client->dev.platform_data;
	}
#else
	pdata = dev->platform_data;
#endif
	if (!pdata)
		return -EINVAL;

	i2c_set_clientdata(client, pca9468_chg);

	mutex_init(&pca9468_chg->lock);
	pca9468_chg->dev = &client->dev;
	pca9468_chg->pdata = pdata;
	pca9468_chg->charging_state = DC_STATE_NO_CHARGING;
	pca9468_chg->wlc_ramp_out_iin = true;
	pca9468_chg->wlc_ramp_out_vout_target = 15300000; /* 15.3V as default */
	pca9468_chg->wlc_ramp_out_delay = 250; /* 250 ms default */

	/* Create a work queue for the direct charger */
	pca9468_chg->dc_wq = alloc_ordered_workqueue("pca9468_dc_wq", WQ_MEM_RECLAIM);
	if (pca9468_chg->dc_wq == NULL) {
		dev_err(pca9468_chg->dev, "failed to create work queue\n");
		return -ENOMEM;
	}

	pca9468_chg->monitor_wake_lock =
		wakeup_source_register(NULL, "pca9468-charger-monitor");
	if (!pca9468_chg->monitor_wake_lock) {
		pr_err("Failed to register wakeup source\n");
		return -ENODEV;
	}

	/* initialize work */
	INIT_DELAYED_WORK(&pca9468_chg->timer_work, pca9468_timer_work);
	pca9468_chg->timer_id = TIMER_ID_NONE;
	pca9468_chg->timer_period = 0;

	INIT_DELAYED_WORK(&pca9468_chg->pps_work, pca9468_pps_request_work);

	ret = of_property_read_string(dev->of_node,
				      "pca9468,psy_name", &psy_name);
	if ((ret == 0) && (strlen(psy_name) > 0))
		pca9468_regmap.name = pca9468_mains_desc.name =
		    devm_kstrdup(dev, psy_name, GFP_KERNEL);

	pca9468_chg->regmap = devm_regmap_init_i2c(client, &pca9468_regmap);
	if (IS_ERR(pca9468_chg->regmap)) {
		ret = -EINVAL;
		goto error;
	}

	ret = pca9468_probe_pps(pca9468_chg);
	if (ret < 0) {
		pr_warn("pca9468: PPS not available (%d)\n", ret);
	} else {
		const char *logname = "pca9468";

		pca9468_chg->log = logbuffer_register(logname);
		if (IS_ERR(pca9468_chg->log)) {
			pr_err("%s: no logbuffer (%ld)\n", __func__,
			       PTR_ERR(pca9468_chg->log));
			pca9468_chg->log = NULL;
		}
	}

	ret = pca9468_hw_ping(pca9468_chg);
	if (ret < 0)
		goto error;

	/* TODO: only enable ADC if usb_tz_name is defined */
	ret = pca9468_hw_init(pca9468_chg);
	if (ret < 0)
		goto error;

	mains_cfg.supplied_to = battery;
	mains_cfg.num_supplicants = ARRAY_SIZE(battery);
	mains_cfg.drv_data = pca9468_chg;
	pca9468_chg->mains = devm_power_supply_register(dev,
							&pca9468_mains_desc,
							&mains_cfg);
	if (IS_ERR(pca9468_chg->mains)) {
		ret = -ENODEV;
		goto error;
	}

	/* Interrupt pin is optional. */
	if (pdata->irq_gpio >= 0) {
		ret = pca9468_irq_init(pca9468_chg, client);
		if (ret < 0) {
			dev_warn(dev, "failed to initialize IRQ: %d\n", ret);
			dev_warn(dev, "disabling IRQ support\n");
		}

		/* disable interrupt */
		disable_irq(client->irq);
	}

	ret = pca9468_create_fs_entries(pca9468_chg);
	if (ret < 0)
		dev_err(dev, "error while registering debugfs %d\n", ret);

#ifdef CONFIG_THERMAL
	if (pdata->usb_tz_name) {
		pca9468_chg->usb_tzd =
			thermal_zone_device_register(pdata->usb_tz_name, 0, 0,
						     pca9468_chg,
						     &pca9468_usb_tzd_ops,
						     NULL, 0, 0);
		if (IS_ERR(pca9468_chg->usb_tzd)) {
			pca9468_chg->usb_tzd = NULL;
			ret = PTR_ERR(pca9468_chg->usb_tzd);
			dev_err(dev, "Couldn't register usb connector thermal zone ret=%d\n",
				ret);
		}
	}
#endif

	pca9468_chg->dc_avail = NULL;

	pca9468_chg->init_done = true;
	pr_info("pca9468: probe_done\n");
	pr_debug("%s: =========END=========\n", __func__);
	return 0;

error:
	destroy_workqueue(pca9468_chg->dc_wq);
	mutex_destroy(&pca9468_chg->lock);
	wakeup_source_unregister(pca9468_chg->monitor_wake_lock);
	return ret;
}

static int pca9468_remove(struct i2c_client *client)
{
	struct pca9468_charger *pca9468_chg = i2c_get_clientdata(client);

	/* stop charging if it is active */
	pca9468_stop_charging(pca9468_chg);

	if (client->irq) {
		free_irq(client->irq, pca9468_chg);
		gpio_free(pca9468_chg->pdata->irq_gpio);
	}

	destroy_workqueue(pca9468_chg->dc_wq);

	wakeup_source_unregister(pca9468_chg->monitor_wake_lock);

#ifdef CONFIG_THERMAL
	if (pca9468_chg->usb_tzd)
		thermal_zone_device_unregister(pca9468_chg->usb_tzd);
#endif
	if (pca9468_chg->log)
		logbuffer_unregister(pca9468_chg->log);
	pps_free(&pca9468_chg->pps_data);

	return 0;
}

static const struct i2c_device_id pca9468_id[] = {
	{ "pca9468", 0 },
	{ }
};
MODULE_DEVICE_TABLE(i2c, pca9468_id);

#if defined(CONFIG_OF)
static struct of_device_id pca9468_i2c_dt_ids[] = {
	{ .compatible = "nxp,pca9468" },
	{ },
};
MODULE_DEVICE_TABLE(of, pca9468_i2c_dt_ids);
#endif /* CONFIG_OF */

#if defined(CONFIG_PM)
#ifdef CONFIG_RTC_HCTOSYS
static int get_current_time(unsigned long *now_tm_sec)
{
	struct rtc_time tm;
	struct rtc_device *rtc;
	int rc;

	rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
	if (rtc == NULL) {
		pr_err("%s: unable to open rtc device (%s)\n",
			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
		return -EINVAL;
	}

	rc = rtc_read_time(rtc, &tm);
	if (rc) {
		pr_err("Error reading rtc device (%s) : %d\n",
			CONFIG_RTC_HCTOSYS_DEVICE, rc);
		goto close_time;
	}

	rc = rtc_valid_tm(&tm);
	if (rc) {
		pr_err("Invalid RTC time (%s): %d\n",
			CONFIG_RTC_HCTOSYS_DEVICE, rc);
		goto close_time;
	}

	*now_tm_sec = rtc_tm_to_time64(&tm);

close_time:
	rtc_class_close(rtc);
	return rc;
}

static void
pca9468_check_and_update_charging_timer(struct pca9468_charger *pca9468)
{
	unsigned long current_time = 0, next_update_time, time_left;

	get_current_time(&current_time);

	if (pca9468->timer_id != TIMER_ID_NONE)	{
		next_update_time = pca9468->last_update_time +
				(pca9468->timer_period / 1000); /* seconds */

		pr_debug("%s: current_time=%ld, next_update_time=%ld\n",
			__func__, current_time, next_update_time);

		if (next_update_time > current_time)
			time_left = next_update_time - current_time;
		else
			time_left = 0;

		mutex_lock(&pca9468->lock);
		pca9468->timer_period = time_left * 1000; /* ms unit */
		mutex_unlock(&pca9468->lock);
		schedule_delayed_work(&pca9468->timer_work,
				msecs_to_jiffies(pca9468->timer_period));

		pr_debug("%s: timer_id=%d, time_period=%ld\n", __func__,
			 pca9468->timer_id, pca9468->timer_period);
	}
	pca9468->last_update_time = current_time;
}
#endif

static int pca9468_suspend(struct device *dev)
{
	struct pca9468_charger *pca9468 = dev_get_drvdata(dev);

	pr_debug("%s: cancel delayed work\n", __func__);

	/* cancel delayed_work */
	cancel_delayed_work(&pca9468->timer_work);
	return 0;
}

static int pca9468_resume(struct device *dev)
{
	struct pca9468_charger *pca9468 = dev_get_drvdata(dev);

	pr_debug("%s: update_timer\n", __func__);

	/* Update the current timer */
#ifdef CONFIG_RTC_HCTOSYS
	pca9468_check_and_update_charging_timer(pca9468);
#else
	if (pca9468->timer_id != TIMER_ID_NONE) {
		mutex_lock(&pca9468->lock);
		pca9468->timer_period = 0;	/* ms unit */
		mutex_unlock(&pca9468->lock);
		schedule_delayed_work(&pca9468->timer_work,
				      msecs_to_jiffies(pca9468->timer_period));
	}
#endif
	return 0;
}
#else
#define pca9468_suspend		NULL
#define pca9468_resume		NULL
#endif

const struct dev_pm_ops pca9468_pm_ops = {
	.suspend = pca9468_suspend,
	.resume = pca9468_resume,
};

static struct i2c_driver pca9468_driver = {
	.driver = {
		.name = "pca9468",
#if defined(CONFIG_OF)
		.of_match_table = pca9468_i2c_dt_ids,
#endif /* CONFIG_OF */
#if defined(CONFIG_PM)
		.pm = &pca9468_pm_ops,
#endif
	},
	.probe        = pca9468_probe,
	.remove       = pca9468_remove,
	.id_table     = pca9468_id,
};

module_i2c_driver(pca9468_driver);

MODULE_AUTHOR("Clark Kim <clark.kim@nxp.com>");
MODULE_AUTHOR("AleX Pelosi <apelosi@google.com>");
MODULE_AUTHOR("Wasb Liu <wasbliu@google.com>");
MODULE_DESCRIPTION("PCA9468 gcharger driver");
MODULE_LICENSE("GPL");
MODULE_VERSION("3.7.0");
