/*
 * P9221 Wireless Charger Driver
 *
 * Copyright 2017-2022 Google LLC
 *
 */

#include <linux/device.h>
#include <linux/crc8.h>
#include <linux/pm.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/gpio/driver.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/alarmtimer.h>
#include "p9221_charger.h"
#include "p9221-dt-bindings.h"
#include "google_dc_pps.h"
#include "google_bms.h"
#include <linux/debugfs.h>

#define P9221R5_OVER_CHECK_NUM		3
#define MFG_CHK_COUNT_MAX		30
#define OVC_LIMIT			1
#define OVC_THRESHOLD			1400000
#define OVC_BACKOFF_LIMIT		900000
#define OVC_BACKOFF_AMOUNT		100000

#define WLC_ALIGNMENT_MAX		100
#define WLC_CURRENT_FILTER_LENGTH	10
#define WLC_ALIGN_DEFAULT_SCALAR	4
#define WLC_ALIGN_IRQ_THRESHOLD		10
#define WLC_ALIGN_DEFAULT_HYSTERESIS	5000
#define WLC_ALIGN_CURRENT_THRESHOLD	450
#define WLC_ALIGN_DEFAULT_SCALAR_LOW_CURRENT	    200
#define WLC_ALIGN_DEFAULT_SCALAR_HIGH_CURRENT	    118
#define WLC_ALIGN_DEFAULT_OFFSET_LOW_CURRENT	    125000
#define WLC_ALIGN_DEFAULT_OFFSET_HIGH_CURRENT	    139000
#define HPP_FOD_VOUT_THRESHOLD_UV	17500000

#define WLC_HPP_SOC_LIMIT	80
#define PROP_MODE_PWR_DEFAULT	30

#define RTX_BEN_DISABLED	0
#define RTX_BEN_ON		1
#define RTX_BEN_ENABLED		2

#define REENABLE_RTX_DELAY	3000
#define P9XXX_CHK_RP_DELAY_MS	200

#define P9XXX_VOUT_5480MV	5480
#define P9XXX_VOUT_5000MV	5000
#define P9XXX_FOD_CHK_DELAY_MS	2000

#define P9XXX_VOUT_5480MV	5480

enum wlc_align_codes {
	WLC_ALIGN_CHECKING = 0,
	WLC_ALIGN_MOVE,
	WLC_ALIGN_CENTERED,
	WLC_ALIGN_ERROR,
};

enum wlc_chg_mode {
	WLC_BPP = 0,
	WLC_EPP,
	WLC_EPP_COMP,
	WLC_HPP,
	WLC_HPP_HV,
};

#define P9221_CRC8_POLYNOMIAL		0x07	/* (x^8) + x^2 + x + 1 */
DECLARE_CRC8_TABLE(p9221_crc8_table);

static void p9221_icl_ramp_reset(struct p9221_charger_data *charger);
static void p9221_icl_ramp_start(struct p9221_charger_data *charger);
static void p9221_charge_stats_init(struct p9221_charge_stats *chg_data);
static void p9221_dump_charge_stats(struct p9221_charger_data *charger);
static bool p9221_check_feature(struct p9221_charger_data *charger, u64 ft);
static const char *p9221_get_tx_id_str(struct p9221_charger_data *charger);
static int p9221_set_bpp_vout(struct p9221_charger_data *charger);
static int p9221_set_hpp_dc_icl(struct p9221_charger_data *charger, bool enable);
static void p9221_ll_bpp_cep(struct p9221_charger_data *charger, int capacity);
static int p9221_ll_check_id(struct p9221_charger_data *charger);

static char *align_status_str[] = {
	"...", "M2C", "OK", "-1"
};

static size_t p9221_hex_str(u8 *data, size_t len, char *buf, size_t max_buf,
			    bool msbfirst)
{
	int i;
	int blen = 0;
	u8 val;

	for (i = 0; i < len; i++) {
		if (msbfirst)
			val = data[len - 1 - i];
		else
			val = data[i];
		blen += scnprintf(buf + (i * 3), max_buf - (i * 3),
				  "%02x ", val);
	}
	return blen;
}

static int p9221_reg_read_n(struct p9221_charger_data *charger, u16 reg,
			    void *buf, size_t n)
{
	int ret;
	struct i2c_msg msg[2];
	u8 wbuf[2];

	msg[0].addr = charger->client->addr;
	msg[0].flags = charger->client->flags & I2C_M_TEN;
	msg[0].len = 2;
	msg[0].buf = wbuf;

	wbuf[0] = (reg & 0xFF00) >> 8;
	wbuf[1] = (reg & 0xFF);

	msg[1].addr = charger->client->addr;
	msg[1].flags = I2C_M_RD;
	msg[1].len = n;
	msg[1].buf = buf;

	mutex_lock(&charger->io_lock);
	ret = i2c_transfer(charger->client->adapter, msg, 2);
	mutex_unlock(&charger->io_lock);

	if (ret < 0) {
		/*
		 * Treat -ENOTCONN as -ENODEV to suppress the get/set
		 * prop warnings.
		 */
		int nret = (ret == -ENOTCONN) ? -ENODEV : ret;

		dev_err(&charger->client->dev,
			"i2c read error, reg:%x, ret:%d (%d)\n",
			reg, ret, nret);
		return nret;
	}

	return (ret == 2) ? 0 : -EIO;
}

static int p9221_reg_read_16(struct p9221_charger_data *charger, u16 reg,
			     u16 *val)
{
	u8 buf[2];
	int ret;

	ret = p9221_reg_read_n(charger, reg, buf, 2);
	if (ret == 0)
		*val = (buf[1] << 8) | buf[0];
	return ret;
}

static int p9221_reg_read_8(struct p9221_charger_data *charger,
			    u16 reg, u8 *val)
{
	return p9221_reg_read_n(charger, reg, val, 1);
}

static int p9221_reg_write_n(struct p9221_charger_data *charger, u16 reg,
			     const void *buf, size_t n)
{
	int ret;
	u8 *data;
	int datalen = 2 + n;

	data = kmalloc(datalen, GFP_KERNEL);
	if (!data)
		return -ENOMEM;

	data[0] = reg >> 8;
	data[1] = reg & 0xFF;
	memcpy(&data[2], buf, n);

	mutex_lock(&charger->io_lock);
	ret = i2c_master_send(charger->client, data, datalen);
	mutex_unlock(&charger->io_lock);
	kfree(data);

	if (ret < datalen) {
		/*
		 * Treat -ENOTCONN as -ENODEV to suppress the get/set
		 * prop warnings.
		 */
		int nret = (ret == -ENOTCONN) ? -ENODEV : -EIO;

		dev_err(&charger->client->dev,
			"%s: i2c write error, reg: 0x%x, n: %zd ret: %d (%d)\n",
			__func__, reg, n, ret, nret);
		return nret;
	}

	return 0;
}

static int p9221_reg_write_16(struct p9221_charger_data *charger, u16 reg,
			      u16 val)
{
	return p9221_reg_write_n(charger, reg, &val, 2);
}

static int p9221_reg_write_8(struct p9221_charger_data *charger, u16 reg,
			     u8 val)
{
	return p9221_reg_write_n(charger, reg, &val, 1);
}

static bool p9221_is_hpp(struct p9221_charger_data *charger)
{
	int ret;
	uint8_t reg = 0;

	ret = charger->chip_get_sys_mode(charger, &reg);

	return ((ret == 0) && (reg == P9XXX_SYS_OP_MODE_PROPRIETARY));
}

bool p9221_is_epp(struct p9221_charger_data *charger)
{
	int ret;
	u32 vout_mv;
	u32 vout_uv;
	uint8_t reg;

	if (!charger->online)
		return false;
	if (charger->fake_force_epp > 0)
		return true;
	if (charger->force_bpp)
		return false;

	/*
	 *  NOTE: mfg may be zero due to race condition during bringup. will
	 *  check once more if mfg == 0.
	 */
	if (charger->mfg == 0) {
		ret = p9xxx_chip_get_tx_mfg_code(charger, &charger->mfg);
		if (ret < 0)
			dev_err(&charger->client->dev,
				"cannot read MFG_CODE (%d)\n", ret);
	}

	charger->is_mfg_google = charger->mfg == WLC_MFG_GOOGLE;

	ret = charger->chip_get_sys_mode(charger, &reg);
	if (ret == 0)
		return ((reg == P9XXX_SYS_OP_MODE_WPC_EXTD) ||
			(reg == P9XXX_SYS_OP_MODE_PROPRIETARY));

	dev_err(&charger->client->dev, "Could not read mode: %d\n",
		ret);

	/* Check based on power supply voltage */
	ret = charger->chip_get_vout(charger, &vout_mv);
	if (ret) {
		dev_err(&charger->client->dev, "Could read VOUT_ADC, %d\n",
			ret);
		goto out;
	}
	vout_uv = P9221_MA_TO_UA(vout_mv);

	dev_info(&charger->client->dev, "Voltage is %duV\n", vout_uv);
	if (vout_uv > P9221_EPP_THRESHOLD_UV)
		return true;

out:
	/* Default to BPP otherwise */
	return false;
}

bool p9xxx_is_capdiv_en(struct p9221_charger_data *charger)
{
	int ret;
	u8 cdmode;

	if (charger->chip_id != P9412_CHIP_ID)
		return false;

	ret = charger->reg_read_8(charger, P9412_CDMODE_STS_REG, &cdmode);
	if ((ret == 0) && (cdmode & CDMODE_CAP_DIV_MODE))
		return true;

	return false;
}

static int p9221_check_fod_by_fsw(struct p9221_charger_data *charger)
{
	const int freq_high_thres = charger->pdata->fod_fsw_high;
	const int freq_low_thres = charger->pdata->fod_fsw_low;
	u32 vout_mv = 0, freq_khz = 0;
	int ret;

	ret = charger->chip_get_vout_max(charger, &vout_mv);
	if (ret == 0 && vout_mv == P9XXX_VOUT_5000MV)
		return WLC_BPP;

	if (!charger->is_mfg_google || freq_high_thres < 0 || freq_low_thres < 0)
		return WLC_EPP;

	ret = charger->chip_get_op_freq(charger, &freq_khz);
	if (ret != 0)
		return WLC_EPP;
	if (freq_khz < freq_low_thres ||
	    (charger->fod_mode == WLC_EPP_COMP && freq_khz < freq_high_thres))
		return WLC_EPP_COMP;

	return WLC_EPP;
}

static void p9221_write_fod(struct p9221_charger_data *charger)
{
	int mode = WLC_BPP;
	u8 *fod = NULL;
	int fod_count = charger->pdata->fod_num;
	int ret;
	int retries = 3;
	static char *wlc_mode[] = { "BPP", "EPP", "EPP_COMP" , "HPP" , "HPP_HV" };


	if (charger->no_fod)
		goto no_fod;

	if (!charger->pdata->fod_num &&
            !charger->pdata->fod_epp_num &&
            !charger->pdata->fod_hpp_num)
		goto no_fod;

	/* Default to BPP FOD */
	if (charger->pdata->fod_num)
		fod = charger->pdata->fod;

	if (p9221_is_epp(charger) && charger->pdata->fod_epp_num) {
		mode = WLC_EPP;
		if (charger->pdata->fod_fsw)
			mode = p9221_check_fod_by_fsw(charger);
		if (mode == WLC_EPP) {
			fod = charger->pdata->fod_epp;
			fod_count = charger->pdata->fod_epp_num;
		} else if (mode == WLC_EPP_COMP) {
			fod = charger->pdata->fod_epp_comp;
			fod_count = charger->pdata->fod_epp_comp_num;
		}
	}

	if (p9xxx_is_capdiv_en(charger) && charger->pdata->fod_hpp_num) {
		fod = charger->pdata->fod_hpp;
		fod_count = charger->pdata->fod_hpp_num;
		mode = WLC_HPP;
		if (charger->hpp_hv && charger->pdata->fod_hpp_hv_num) {
			fod = charger->pdata->fod_hpp_hv;
			fod_count = charger->pdata->fod_hpp_hv_num;
			mode = WLC_HPP_HV;
		}
	}

	if (mode == charger->fod_mode)
		goto done;

	charger->fod_mode = mode;

	if (!fod)
		goto no_fod;

	while (retries) {
		char s[P9221R5_NUM_FOD * 3 + 1];
		u8 fod_read[P9221R5_NUM_FOD];

		dev_info(&charger->client->dev,
			 "Writing %s FOD (n=%d reg=%02x try=%d)\n",
			 wlc_mode[mode], fod_count,
			 charger->reg_set_fod_addr, retries);

		ret = p9xxx_chip_set_fod_reg(charger, fod, fod_count);
		if (ret) {
			dev_err(&charger->client->dev,
				"Could not write FOD: %d\n", ret);
			return;
		}

		/* Verify the FOD has been written properly */
		ret = p9xxx_chip_get_fod_reg(charger, fod_read, fod_count);
		if (ret) {
			dev_err(&charger->client->dev,
				"Could not read back FOD: %d\n", ret);
			return;
		}

		if (memcmp(fod, fod_read, fod_count) == 0)
			goto done;

		p9221_hex_str(fod_read, fod_count, s, sizeof(s), 0);
		dev_err(&charger->client->dev,
			"FOD verify error, read: %s\n", s);

		retries--;
		msleep(100);
	}

no_fod:
	dev_warn(&charger->client->dev, "FOD not set! bpp:%d epp:%d hpp:%d hpp_hv:%d r:%d\n",
		 charger->pdata->fod_num, charger->pdata->fod_epp_num,
		 charger->pdata->fod_hpp_num, charger->pdata->fod_hpp_hv_num, retries);
done:
	if (charger->pdata->fod_fsw)
		mod_delayed_work(system_wq, &charger->chk_fod_work,
				 msecs_to_jiffies(P9XXX_FOD_CHK_DELAY_MS));
}

#define CC_DATA_LOCK_MS		250

static int p9221_send_data(struct p9221_charger_data *charger)
{
	int ret;
	ktime_t now = get_boot_msec();

	if (charger->cc_data_lock.cc_use &&
	    charger->cc_data_lock.cc_rcv_at != 0 &&
	    (now - charger->cc_data_lock.cc_rcv_at > CC_DATA_LOCK_MS))
		charger->cc_data_lock.cc_use = false;

	if (charger->cc_data_lock.cc_use)
		return -EBUSY;

	if (charger->tx_busy)
		return -EBUSY;

	charger->tx_busy = true;

	mutex_lock(&charger->cmd_lock);

	ret = charger->chip_set_data_buf(charger, charger->tx_buf, charger->tx_len);
	if (ret) {
		dev_err(&charger->client->dev, "Failed to load tx %d\n", ret);
		goto error;
	}

	ret = charger->chip_set_cc_send_size(charger, charger->tx_len);
	if (ret) {
		dev_err(&charger->client->dev, "Failed to load txsz %d\n", ret);
		goto error;
	}

	ret = charger->chip_set_cmd(charger, charger->set_cmd_ccactivate_bit);
	if (ret)
		goto error;

	mutex_unlock(&charger->cmd_lock);
	return ret;

error:
	mutex_unlock(&charger->cmd_lock);
	charger->tx_busy = false;
	return ret;
}

static int p9221_send_ccreset(struct p9221_charger_data *charger);

/* call with lock on mutex_lock(&charger->stats_lock) */
static int p9221_send_csp(struct p9221_charger_data *charger, u8 stat)
{
	int ret = 0;
	const bool no_csp = charger->ben_state &&
			    charger->ints.pppsent_bit &&
			    charger->com_busy;

	if (no_csp) {
		charger->last_capacity = -1;
		if (charger->com_busy >= COM_BUSY_MAX) {
			if (p9221_send_ccreset(charger) == 0)
				charger->com_busy = 0;
		} else {
			charger->com_busy += 1;
		}
		logbuffer_log(charger->rtx_log,
			     "com_busy=%d, did not send csp",
			     charger->com_busy);
		return ret;
	}

	mutex_lock(&charger->cmd_lock);

	if (charger->ben_state) {
		ret = charger->chip_send_csp_in_txmode(charger, stat);
		if (ret == 0)
			charger->com_busy += 1;
	}

	if (charger->online) {
		ret = p9221_reg_write_8(charger, charger->reg_csp_addr, stat);
		if (ret == 0)
			ret = charger->chip_set_cmd(charger, P9221R5_COM_SENDCSP);
		if (ret < 0)
			dev_info(&charger->client->dev, "Send CSP status=%d (%d)\n",
				 stat, ret);
	}

	mutex_unlock(&charger->cmd_lock);
	return ret;
}

u8 p9221_crc8(u8 *pdata, size_t nbytes, u8 crc)
{
	return crc8(p9221_crc8_table, pdata, nbytes, crc);
}

static bool p9221_is_online(const struct p9221_charger_data *charger)
{
	return charger->online || charger->ben_state;
}

static int p9221_ready_to_read(struct p9221_charger_data *charger)
{
	pm_runtime_get_sync(charger->dev);
	if (!charger->resume_complete) {
		pm_runtime_put_sync(charger->dev);
		return -EAGAIN;
	}
	pm_runtime_put_sync(charger->dev);

	if (!p9221_is_online(charger))
		return -ENODEV;

	return 0;
}

static int set_renego_state(struct p9221_charger_data *charger, enum p9xxx_renego_state state)
{
	mutex_lock(&charger->renego_lock);
	if (state == P9XXX_AVAILABLE ||
	    charger->renego_state == P9XXX_AVAILABLE) {
		charger->renego_state = state;
		mutex_unlock(&charger->renego_lock);
		return 0;
	}
	mutex_unlock(&charger->renego_lock);

	dev_warn(&charger->client->dev, "Not allowed due to renego_state=%d\n", charger->renego_state);
	return -EAGAIN;
}

static int p9221_send_ccreset(struct p9221_charger_data *charger)
{
	set_renego_state(charger, P9XXX_AVAILABLE);
	return charger->chip_send_ccreset(charger);
}


static void p9221_abort_transfers(struct p9221_charger_data *charger)
{
	/* Abort all transfers */
	cancel_delayed_work(&charger->tx_work);
	charger->tx_busy = false;
	charger->tx_done = true;
	charger->rx_done = true;
	charger->rx_len = 0;
	set_renego_state(charger, P9XXX_AVAILABLE);
	sysfs_notify(&charger->dev->kobj, NULL, "txbusy");
	sysfs_notify(&charger->dev->kobj, NULL, "txdone");
	sysfs_notify(&charger->dev->kobj, NULL, "rxdone");
}

/*
 * Put the default ICL back to BPP, reset OCP voter
 * @pre charger && charger->dc_icl_votable && charger->client->dev
 */
static void p9221_vote_defaults(struct p9221_charger_data *charger)
{
	int ret, ocp_icl;

	if (!charger->dc_icl_votable) {
		dev_err(&charger->client->dev,
			"Could not vote DC_ICL - no votable\n");
		return;
	}

	ret = gvotable_cast_long_vote(charger->dc_icl_votable, P9221_WLC_VOTER,
				      P9221_DC_ICL_BPP_UA, true);
	if (ret)
		dev_err(&charger->client->dev,
			"Could not vote DC_ICL %d\n", ret);

	ocp_icl = (charger->dc_icl_epp > 0) ?
		   charger->dc_icl_epp : P9221_DC_ICL_EPP_UA;

	ret = gvotable_cast_int_vote(charger->dc_icl_votable,
				     P9221_OCP_VOTER, ocp_icl, true);
	if (ret)
		dev_err(&charger->client->dev,
			"Could not reset OCP DC_ICL voter %d\n", ret);

	/* TODO: convert all to gvotable_recast_ballot() */
	gvotable_cast_int_vote(charger->dc_icl_votable,
			       P9382A_RTX_VOTER, 0, false);
	gvotable_cast_int_vote(charger->dc_icl_votable,
			       DCIN_AICL_VOTER, 0, false);
	gvotable_cast_int_vote(charger->dc_icl_votable,
			       HPP_DC_ICL_VOTER, 0, false);
	gvotable_cast_int_vote(charger->dc_icl_votable,
			       DD_VOTER, 0, false);
	gvotable_recast_ballot(charger->dc_icl_votable,
			       LL_BPP_CEP_VOTER, false);

	p9221_set_auth_dc_icl(charger, false);
	gvotable_cast_int_vote(charger->dc_icl_votable,
			       P9221_RAMP_VOTER, 0, false);
	gvotable_cast_int_vote(charger->dc_icl_votable,
			       P9221_HPP_VOTER, 0, false);
}

static int p9221_set_switch_reg(struct p9221_charger_data *charger, bool enable)
{
	u8 swreg;
	int ret = p9221_reg_read_8(charger, P9412_V5P0AP_SWITCH_REG, &swreg);
	if (ret < 0) {
		dev_warn(&charger->client->dev,
			 "Failed to read swreg (%d)\n", ret);
		return ret;
	}
	if (enable)
		swreg |= V5P0AP_SWITCH_EN;
	else
		swreg &= ~V5P0AP_SWITCH_EN;
	return p9221_reg_write_8(charger, P9412_V5P0AP_SWITCH_REG, swreg);
}

#define EPP_MODE_REQ_PWR		15
#define EPP_MODE_REQ_VOUT		12000
#define WLC_VOUT_RAMP_DOWN_MV		15300
#define WLC_VOUT_CFG_STEP		40		/* b/194346461 ramp down VOUT */
static int p9xxx_set_bypass_mode(struct p9221_charger_data *charger)
{
	const int req_pwr = EPP_MODE_REQ_PWR;
	const int vout_target = WLC_VOUT_RAMP_DOWN_MV;
	int i, count, ret;
	u8 cdmode, currpwr;
	u32 vout_mv;

	if (!charger->online)
		return 0;

	/* Check it's in Cap Div mode */
	ret = charger->reg_read_8(charger, P9412_CDMODE_STS_REG, &cdmode);
	if (ret || (cdmode & CDMODE_BYPASS_MODE))
		return ret;
	dev_info(&charger->client->dev, "cdmode_reg=%02x\n", cdmode);

	usleep_range(500 * USEC_PER_MSEC, 510 * USEC_PER_MSEC);
	/* Ramp down WLC Vout to 15.3V */
	while (true) {
		ret = charger->chip_get_vout(charger, &vout_mv);
		if (ret < 0 || vout_mv == 0) {
			dev_err(&charger->client->dev, "%s: invalid vout %d\n", __func__, ret);
			return ret;
		}

		if (vout_mv < vout_target) {
			dev_info(&charger->client->dev, "%s: underflow vout=%d, (target=%d)\n",
				 __func__, vout_mv, vout_target);
			break;
		}

		vout_mv -= WLC_VOUT_CFG_STEP;

		ret = charger->chip_set_vout_max(charger, vout_mv);
		if (ret < 0) {
			dev_err(&charger->client->dev, "%s: cannot set vout %d\n", __func__, ret);
			return ret;
		} else {
			dev_info(&charger->client->dev, "%s: vout set to %d\n", __func__, vout_mv);
			usleep_range(250 * USEC_PER_MSEC, 260 * USEC_PER_MSEC);
		}
	}

	if (!charger->online)
		return 0;

	usleep_range(500 * USEC_PER_MSEC, 510 * USEC_PER_MSEC);
	for (count = 0; count < 3; count++) {
		/* Change the Requested Power to 15W */
		ret = charger->reg_write_8(charger, P9412_PROP_REQ_PWR_REG, req_pwr * 2);
		if (ret == 0)
			ret = charger->chip_set_cmd(charger, PROP_REQ_PWR_CMD);
		if (ret)
			dev_warn(&charger->client->dev,
				 "Fail to request Tx power(%d)\n", ret);

		/* total 5 seconds wait and early exit when WLC offline */
		for (i = 0; i < 50; i += 1) {
			usleep_range(100 * USEC_PER_MSEC, 120 * USEC_PER_MSEC);
			if (!charger->online) {
				dev_err(&charger->client->dev, "%s: WLC offline\n", __func__);
				return -ENODEV;
			}
		}

		/* Check PropCurrPwr and P9412 Vout */
		vout_mv = 0;
		currpwr = 0;
		ret = charger->chip_get_vout(charger, &vout_mv);
		ret |= charger->reg_read_8(charger, P9412_PROP_CURR_PWR_REG, &currpwr);
		dev_info(&charger->client->dev, "count=%d, currpwr=%02x, vout_mv=%u\n",
			 count, currpwr, vout_mv);
		if (ret == 0 && currpwr == (req_pwr * 2) && vout_mv < EPP_MODE_REQ_VOUT)
			break;
	}

	if (count == 3) {
		dev_err(&charger->client->dev, "%s: timeout for change to bypass mode\n", __func__);
		return -ETIMEDOUT;
	}

	/* Request Bypass mode */
	ret = charger->chip_capdiv_en(charger, CDMODE_BYPASS_MODE);
	if (ret) {
		u8 mode_sts = 0, err_sts = 0;
		int rc;

		rc = charger->reg_read_8(charger, P9412_PROP_MODE_STATUS_REG, &mode_sts);
		rc |= charger->reg_read_8(charger, P9412_PROP_MODE_ERR_STS_REG, &err_sts);
		dev_err(&charger->client->dev,
			"Fail to change to bypass mode(%d), rc=%d sts=%02x, err=%02x\n",
			ret, rc, mode_sts, err_sts);
	}

	return ret;
}

static int p9221_reset_wlc_dc(struct p9221_charger_data *charger)
{
	const int dc_sw_gpio = charger->pdata->dc_switch_gpio;
	const int extben_gpio = charger->pdata->ext_ben_gpio;
	int ret;

	if (!charger->pdata->has_wlc_dc)
		return -EOPNOTSUPP;

	charger->wlc_dc_enabled = false;

	usleep_range(500 * USEC_PER_MSEC, 510 * USEC_PER_MSEC);
	p9xxx_gpio_set_value(charger, dc_sw_gpio, 0);
	p9xxx_gpio_set_value(charger, extben_gpio, 0);

	p9221_set_switch_reg(charger, false);

	ret = p9221_set_hpp_dc_icl(charger, false);
	if (ret < 0)
		dev_warn(&charger->client->dev, "Cannot disable HPP_ICL (%d)\n", ret);

	gvotable_cast_int_vote(charger->dc_icl_votable, P9221_HPP_VOTER, 0, false);

	ret = p9xxx_set_bypass_mode(charger);
	if (ret) {
		/*
		 * going to go offline and reset the state when
		 * 1. fail to change to bypass mode
		 * 2. WLC offline(normal)
		 * 3. MW wcin is 0 but WLC chip Vout > 0
		 */
		gvotable_cast_bool_vote(charger->wlc_disable_votable,
					P9221_HPP_VOTER, true);
		usleep_range(200 * USEC_PER_MSEC, 220 * USEC_PER_MSEC);
		gvotable_cast_bool_vote(charger->wlc_disable_votable,
					P9221_HPP_VOTER, false);
	} else {
		charger->prop_mode_en = false;
		p9221_write_fod(charger);
	}

	ret = p9221_reg_write_8(charger, P9412_MOT_REG, P9412_MOT_65PCT);
	if (ret < 0)
		dev_warn(&charger->client->dev, "Fail to set MOT register(%d)\n", ret);

	return ret;
}

#define CHARGE_15W_VOUT_UV	12000000
#define CHARGE_15W_ILIM_UA	1270000

/* call holding mutex_lock(&charger->auth_lock); */
static int feature_set_dc_icl(struct p9221_charger_data *charger, u32 ilim_ua)
{
	/*
	 * TODO: use p9221_icl_ramp_start(charger) for ilim_ua.
	 * Need to make sure that charger->pdata->icl_ramp_delay_ms is set.
	 */
	charger->icl_ramp_alt_ua = ilim_ua > 0 ? ilim_ua : 0;
	p9221_set_auth_dc_icl(charger, false);
	p9221_icl_ramp_reset(charger);

	dev_info(&charger->client->dev, "ICL ramp set alarm %dms, %dua, ramp=%d\n",
		 charger->pdata->icl_ramp_delay_ms, charger->icl_ramp_alt_ua,
		 charger->icl_ramp);

	/* can I just shorcut the 0? */
	alarm_start_relative(&charger->icl_ramp_alarm,
			     ms_to_ktime(charger->pdata->icl_ramp_delay_ms));
	return 0;
}

/* call with mutex_lock(&charger->feat_lock); */
static int feature_15w_enable(struct p9221_charger_data *charger, bool enable)
{
	struct p9221_charger_feature *chg_fts = &charger->chg_features;
	int ret = 0;

	pr_debug("%s: enable=%d chip_id=%x\n", __func__, enable,
		 charger->pdata->chip_id);

	/* wc_vol =12V & wc_cur = 1.27A */
	if (enable && !(chg_fts->session_features & WLCF_CHARGE_15W)) {
		const u32 vout_mv = P9221_UV_TO_MV(CHARGE_15W_VOUT_UV);

		if (charger->pdata->chip_id != P9412_CHIP_ID)
			return -ENOTSUPP;

		/* TODO: feature_set_dc_icl() needs mutex_lock(&charger->auth_lock); */
		ret = charger->chip_set_vout_max(charger, vout_mv);
		if (ret == 0)
			ret = feature_set_dc_icl(charger, CHARGE_15W_ILIM_UA);
		if (ret == 0)
			ret = gvotable_cast_long_vote(charger->dc_icl_votable,
						      P9221_OCP_VOTER,
						      CHARGE_15W_ILIM_UA,
						      true);
		/* TODO: feature_set_dc_icl() needs mutex_unlock(&charger->auth_lock); */
	} else if (!enable && (chg_fts->session_features & WLCF_CHARGE_15W)) {
		const u32 vout_mv = P9221_UV_TO_MV(P9221_EPP_THRESHOLD_UV);
		const int ocp_icl = (charger->dc_icl_epp > 0) ?
				    charger->dc_icl_epp : P9221_DC_ICL_EPP_UA;
		int rc1, rc2, rc3;

		/* WLCF_CHARGE_15W is not not set on !P9412_CHIP_ID */

		/* offline might have reset this already */
		rc1 = gvotable_cast_long_vote(charger->dc_icl_votable,
					      P9221_OCP_VOTER, ocp_icl,
					      true);
		if (rc1 < 0)
			dev_err(&charger->client->dev, "15W: cannot reset ocp_icl (%d)", rc1);
		/* reset ramp */
		rc2 = feature_set_dc_icl(charger, -1);
		if (rc2 < 0)
			dev_err(&charger->client->dev, "15W: cannot reset ramp (%d)", rc2);
		/* reset VOUT will fail if online */
		rc3 = charger->chip_set_vout_max(charger, vout_mv);
		if (rc3 < 0)
			dev_dbg(&charger->client->dev, "15W: cannot reset vout (%d)", rc3);

		ret = rc1 < 0 || rc2 < 0 ? -EIO : 0;
	}

	return ret;
}

#define FEAT_SESSION_SUPPORTED \
	(WLCF_DREAM_DEFEND | WLCF_DREAM_ALIGN | WLCF_FAST_CHARGE | WLCF_CHARGE_15W)

/* handle the session properties here */
static int feature_update_session(struct p9221_charger_data *charger, u64 ft)
{
	struct p9221_charger_feature *chg_fts = &charger->chg_features;
	u64 session_features;
	int ret;

	mutex_lock(&chg_fts->feat_lock);
	session_features = chg_fts->session_features;

	pr_debug("%s: ft=%llx", __func__, ft);

	/* change the valid (and add code if needed) */
	if (ft & ~FEAT_SESSION_SUPPORTED)
		dev_warn(charger->dev, "unsupported features ft=%llx\n", ft);

	if (ft & WLCF_DREAM_DEFEND)
		chg_fts->session_features |= WLCF_DREAM_DEFEND;
	else
		chg_fts->session_features &= ~WLCF_DREAM_DEFEND;

	if (ft & WLCF_DREAM_ALIGN) {
		chg_fts->session_features |= WLCF_DREAM_ALIGN;
	} else if (chg_fts->session_features & WLCF_DREAM_ALIGN) {
		/* TODO: kill aligmnent aid? */
		chg_fts->session_features &= ~WLCF_DREAM_ALIGN;
	}

	if (ft & WLCF_FAST_CHARGE) {
		chg_fts->session_features |= WLCF_FAST_CHARGE;
	} else if (chg_fts->session_features & WLCF_FAST_CHARGE) {

		if (charger->online)
			dev_warn(&charger->client->dev,
				 "Cannot disable FAST_CHARGE while online\n");

		/*
		 * WLCF_FAST_CHARGE enables HPP when supported.
		 * TODO: gracefully degrade to 15W otherwise.
		 */
		chg_fts->session_features &= ~WLCF_FAST_CHARGE;
	}

	/* this might fail in interesting ways */
	ret = feature_15w_enable(charger, ft & WLCF_CHARGE_15W);
	if (ret < 0) {
		const bool enable = (ft & WLCF_CHARGE_15W) != 0;

		dev_warn(&charger->client->dev, "error on feat 15W ena=%d ret=%d\n",
			 enable, ret);

		/*
		 * -EINVAL, -ENOTSUPP or an I/O error.
		 * TODO report the failure in the session_features
		 */
	} else if (ft & WLCF_CHARGE_15W) {
		chg_fts->session_features |= WLCF_CHARGE_15W;
	} else {
		chg_fts->session_features &= ~WLCF_CHARGE_15W;
		charger->icl_ramp_alt_ua = 0; /* TODO cleanup the interface */
	}

	/* warn when a feature doesn't have a rule and align session_features */
	if (session_features != ft)
		logbuffer_log(charger->log, "session features %llx->%llx [%llx]",
			      session_features, ft, chg_fts->session_features);
	chg_fts->session_features = ft;

	mutex_unlock(&chg_fts->feat_lock);
	return 0;
}

static void p9221_set_offline(struct p9221_charger_data *charger)
{
	if (charger->fod_cnt == 0) {
		/* already change to BPP or not doing power_mitigation */
		cancel_delayed_work(&charger->power_mitigation_work);
		charger->trigger_power_mitigation = false;
		charger->wait_for_online = false;
	} else {
		charger->wait_for_online = true;
		schedule_delayed_work(&charger->power_mitigation_work,
				      msecs_to_jiffies(
					  P9221_POWER_MITIGATE_DELAY_MS));
	}

	dev_info(&charger->client->dev, "Set offline\n");

	mutex_lock(&charger->stats_lock);
	charger->online = false;
	charger->online_at = 0;
	charger->check_rp = RP_NOTSET;
	cancel_delayed_work(&charger->charge_stats_work);
	p9221_dump_charge_stats(charger);
	mutex_unlock(&charger->stats_lock);

	charger->sw_ramp_done = false;
	charger->force_bpp = false;
	charger->chg_on_rtx = false;
	if (!charger->wait_for_online)
		p9221_reset_wlc_dc(charger);
	charger->prop_mode_en = false;
	charger->hpp_hv = false;
	charger->fod_mode = -1;
	set_renego_state(charger, P9XXX_AVAILABLE);

	/* Reset PP buf so we can get a new serial number next time around */
	charger->pp_buf_valid = false;
	memset(charger->pp_buf, 0, sizeof(charger->pp_buf));
	charger->rtx_csp = 0;

	p9221_abort_transfers(charger);
	cancel_delayed_work(&charger->dcin_work);

	/* Reset alignment value when charger goes offline */
	cancel_delayed_work(&charger->align_work);
	charger->align = WLC_ALIGN_ERROR;
	charger->align_count = 0;
	charger->alignment = -1;
	charger->alignment_capable = ALIGN_MFG_FAILED;
	charger->mfg = 0;
	charger->tx_id = 0;
	schedule_work(&charger->uevent_work);

	p9221_icl_ramp_reset(charger);
	del_timer(&charger->vrect_timer);

	/* clear all session features */
	if (!charger->wait_for_online) {
		charger->ll_bpp_cep = -EINVAL;
		feature_update_session(charger, WLCF_DISABLE_ALL_FEATURE);
	}

	p9221_vote_defaults(charger);
	if (charger->enabled)
		mod_delayed_work(system_wq, &charger->dcin_pon_work,
				 msecs_to_jiffies(P9221_DCIN_PON_DELAY_MS));

	logbuffer_log(charger->log, "offline\n");
}

static void p9221_tx_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, tx_work.work);

	dev_info(&charger->client->dev, "timeout waiting for tx complete\n");

	set_renego_state(charger, P9XXX_AVAILABLE);
	charger->tx_busy = false;
	charger->tx_done = true;
	sysfs_notify(&charger->dev->kobj, NULL, "txbusy");
	sysfs_notify(&charger->dev->kobj, NULL, "txdone");
}

static void p9221_vrect_timer_handler(struct timer_list *t)
{
	struct p9221_charger_data *charger = from_timer(charger,
							t, vrect_timer);

	if (charger->align == WLC_ALIGN_CHECKING) {
		charger->align = WLC_ALIGN_MOVE;
		logbuffer_log(charger->log, "align: state: %s",
			      align_status_str[charger->align]);
		schedule_work(&charger->uevent_work);
	}
	dev_info(&charger->client->dev,
		 "timeout waiting for VRECT, online=%d\n", charger->online);
	logbuffer_log(charger->log,
		"vrect: timeout online=%d", charger->online);

	mod_timer(&charger->align_timer,
		  jiffies + msecs_to_jiffies(P9221_ALIGN_TIMEOUT_MS));

	pm_relax(charger->dev);
}

static void p9221_align_timer_handler(struct timer_list *t)
{
	struct p9221_charger_data *charger = from_timer(charger,
							t, align_timer);

	charger->align = WLC_ALIGN_ERROR;
	logbuffer_log(charger->log, "align: timeout no IRQ");
	schedule_work(&charger->uevent_work);
}

#ifdef CONFIG_DC_RESET
/*
 * Offline disables ->qien_gpio: this worker re-enable it P9221_DCIN_TIMEOUT_MS
 * ms later to make sure that the WLC IC goes through a full reset.
 */
static void p9221_dcin_pon_work(struct work_struct *work)
{
	int ret;
	union power_supply_propval prop;
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, dcin_pon_work.work);

	if (!charger->dc_psy)
		return;

	ret = power_supply_get_property(charger->dc_psy,
					POWER_SUPPLY_PROP_DC_RESET, &prop);
	if (ret < 0) {
		dev_err(&charger->client->dev,
			"unable to get DC_RESET, ret=%d\n", ret);
		return;
	}

	if (prop.intval != 0) {
		/* Signal DC_RESET when vout keeps on 1. */
		ret = power_supply_set_property(charger->dc_psy,
						POWER_SUPPLY_PROP_DC_RESET,
						&prop);
		if (ret < 0)
			dev_err(&charger->client->dev,
				"unable to set DC_RESET, ret=%d", ret);

		schedule_delayed_work(&charger->dcin_pon_work,
			msecs_to_jiffies(P9221_DCIN_TIMEOUT_MS));
	}
}
#else
static void p9221_dcin_pon_work(struct work_struct *work)
{

}
#endif

static void p9221_dcin_work(struct work_struct *work)
{
	int res;
	u16 status_reg = 0;
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, dcin_work.work);

	res = p9221_reg_read_16(charger, P9221_STATUS_REG, &status_reg);
	if (res != 0) {
		dev_info(&charger->client->dev,
			"timeout waiting for dc-in, online=%d\n",
			charger->online);
		logbuffer_log(charger->log,
			"dc_in: timeout online=%d", charger->online);

		if (charger->online)
			p9221_set_offline(charger);

		power_supply_changed(charger->wc_psy);
		pm_relax(charger->dev);

		return;
	}

	schedule_delayed_work(&charger->dcin_work,
			msecs_to_jiffies(P9221_DCIN_TIMEOUT_MS));
	logbuffer_log(charger->log, "dc_in: check online=%d status=%x",
			charger->online, status_reg);
}

static void force_set_fod(struct p9221_charger_data *charger)
{
	u8 fod[P9221R5_NUM_FOD] = { 0 };
	int ret;

	if (p9221_is_hpp(charger)) {
		dev_info(&charger->client->dev,
			"power_mitigate: send EOP for revert to BPP\n");
		ret = charger->chip_send_eop(charger, P9221_EOP_REVERT_TO_BPP);
	} else {
		dev_info(&charger->client->dev, "power_mitigate: write 0 to fod\n");
		ret = p9xxx_chip_set_fod_reg(charger, fod, P9221R5_NUM_FOD);
	}
	if (ret)
		dev_err(&charger->client->dev,
			"power_mitigate: failed, ret=%d\n", ret);
}

static void p9221_power_mitigation_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, power_mitigation_work.work);
	int ret = 0;

	charger->wait_for_online = false;

	if (!p9221_is_online(charger)) {
		dev_info(&charger->client->dev, "power_mitigate: offline\n");
		charger->fod_cnt = 0;
		charger->trigger_power_mitigation = false;
		charger->ll_bpp_cep = -EINVAL;
		feature_update_session(charger, WLCF_DISABLE_ALL_FEATURE);
		power_supply_changed(charger->wc_psy);
		return;
	}

	if (!p9221_is_epp(charger)) {
		/* only for LL */
		if (charger->trigger_power_mitigation && charger->ll_bpp_cep == 1) {
			dev_info(&charger->client->dev,
				 "power_mitigate: change Vout to %d mV and disable CMFET\n",
				 P9XXX_VOUT_5480MV);
			ret = charger->chip_set_vout_max(charger, P9XXX_VOUT_5480MV);
			ret |= p9221_reg_write_8(charger, P9412_CMFET_L_REG, 0);
			if (ret < 0)
				dev_err(&charger->client->dev, "Fail to configure LL\n");
			p9221_ll_bpp_cep(charger, charger->last_capacity);
		}
		charger->fod_cnt = 0;
		dev_info(&charger->client->dev, "power_mitigate: already BPP\n");
		return;
	}

	/*
	 * Align supported only for mfg=0x72.
	 * NOTE: need to have this check for compat mode.
	 */
	if (charger->mfg != WLC_MFG_GOOGLE ||
	    !p9221_check_feature(charger, WLCF_DREAM_DEFEND)) {
		const char *txid = p9221_get_tx_id_str(charger);

		dev_info(&charger->client->dev,
			 "power_mitigate: not DD mfg=%x, id=%s\n",
			 charger->mfg, txid ? txid : "<>");
		return;
	}

	if (charger->fod_cnt < P9221_FOD_MAX_TIMES) {
		force_set_fod(charger);
		charger->fod_cnt++;
		dev_info(&charger->client->dev,
			 "power_mitigate: send FOD, cnt=%d\n",
			 charger->fod_cnt);
	} else {
		dev_info(&charger->client->dev,
			 "power_mitigate: power mitigation fail!\n");
		charger->fod_cnt = 0;
	}
}

static void p9221_init_align(struct p9221_charger_data *charger)
{
	/* Reset values used for alignment */
	charger->alignment_last = -1;
	charger->current_filtered = 0;
	charger->current_sample_cnt = 0;
	charger->mfg_check_count = 0;
	/* Disable misaligned message in high power mode, b/159066422 */
	if (!charger->online || charger->prop_mode_en == true) {
		charger->align = WLC_ALIGN_CENTERED;
		return;
	}
	schedule_delayed_work(&charger->align_work,
			      msecs_to_jiffies(P9221_ALIGN_DELAY_MS));
}

static void p9xxx_align_check(struct p9221_charger_data *charger)
{
	int res, wlc_freq_threshold;
	u32 wlc_freq, current_scaling = 0, current_temp;

	current_temp = (charger->current_filtered > 100) ? (charger->current_filtered - 100) : 0;
	if (charger->current_filtered <= charger->pdata->alignment_current_threshold) {
		current_scaling =
			charger->pdata->alignment_scalar_low_current *
			current_temp / 10;
		wlc_freq_threshold =
			charger->pdata->alignment_offset_low_current +
			current_scaling;
	} else {
		current_scaling =
			charger->pdata->alignment_scalar_high_current *
			current_temp / 10;
		wlc_freq_threshold =
			charger->pdata->alignment_offset_high_current -
			current_scaling;
	}

	res = charger->chip_get_op_freq(charger, &wlc_freq);
	if (res != 0) {
		logbuffer_log(charger->log, "align: failed to read op_freq");
		return;
	}
	wlc_freq = P9221_KHZ_TO_HZ(wlc_freq);

	if (wlc_freq < wlc_freq_threshold)
		charger->alignment = 0;
	else
		charger->alignment = 100;

	if (charger->alignment != charger->alignment_last) {
		logbuffer_log(charger->log,
			      "align: alignment=%i. op_freq=%u. current_avg=%u",
			      charger->alignment, wlc_freq,
			      charger->current_filtered);
		charger->alignment_last = charger->alignment;
		schedule_work(&charger->uevent_work);
	}
}

static void p9221_align_check(struct p9221_charger_data *charger,
			      u32 current_scaling)
{
	int res, align_buckets, i, wlc_freq_threshold, wlc_adj_freq;
	u32 wlc_freq;

	res = charger->chip_get_op_freq(charger, &wlc_freq);
	if (res != 0) {
		logbuffer_log(charger->log, "align: failed to read op_freq");
		return;
	}
	wlc_freq = P9221_KHZ_TO_HZ(wlc_freq);

	align_buckets = charger->pdata->nb_alignment_freq - 1;

	charger->alignment = -1;
	wlc_adj_freq = wlc_freq + current_scaling;

	if (wlc_adj_freq < charger->pdata->alignment_freq[0]) {
		logbuffer_log(charger->log, "align: freq below range");
		return;
	}

	for (i = 0; i < align_buckets; i += 1) {
		if ((wlc_adj_freq > charger->pdata->alignment_freq[i]) &&
		    (wlc_adj_freq <= charger->pdata->alignment_freq[i + 1])) {
			charger->alignment = (WLC_ALIGNMENT_MAX * i) /
					     (align_buckets - 1);
			break;
		}
	}

	if (i >= align_buckets) {
		logbuffer_log(charger->log, "align: freq above range");
		return;
	}

	if (charger->alignment == charger->alignment_last)
		return;

	/*
	 *  Frequency needs to be higher than frequency + hysteresis before
	 *  increasing alignment score.
	 */
	wlc_freq_threshold = charger->pdata->alignment_freq[i] +
			     charger->pdata->alignment_hysteresis;

	if ((charger->alignment < charger->alignment_last) ||
	    (wlc_adj_freq >= wlc_freq_threshold)) {
		logbuffer_log(charger->log,
			      "align: alignment=%i. op_freq=%u. current_avg=%u",
			      charger->alignment, wlc_freq,
			      charger->current_filtered);
		charger->alignment_last = charger->alignment;
		schedule_work(&charger->uevent_work);
	}
}

static void p9221_align_work(struct work_struct *work)
{
	int res;
	u16 current_filter_sample;
	u32 current_now;
	u32 current_scaling = 0;

	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, align_work.work);

	if ((charger->chip_id == P9221_CHIP_ID) &&
	    (charger->pdata->alignment_freq == NULL))
		return;

	/* reset the alignment value */
	charger->alignment = -1;

	/* b/159066422 Disable misaligned message in high power mode */
	if (!charger->online || charger->prop_mode_en == true) {
		charger->align = WLC_ALIGN_CENTERED;
		schedule_work(&charger->uevent_work);
		return;
	}

	/* take the align_ws, must be released */
	__pm_stay_awake(charger->align_ws);

	if (charger->alignment_capable == ALIGN_MFG_CHECKING) {
		charger->mfg_check_count += 1;

		res = p9xxx_chip_get_tx_mfg_code(charger, &charger->mfg);
		if (res < 0) {
			dev_err(&charger->client->dev,
				"cannot read MFG_CODE (%d)\n", res);
			goto align_again;
		}

		/* No mfg update. Will check again on next schedule */
		if (charger->mfg == 0)
			goto align_again;

		if ((charger->mfg != WLC_MFG_GOOGLE) ||
		    !p9221_is_epp(charger)) {
			logbuffer_log(charger->log,
				      "align: not align capable mfg: 0x%x",
				      charger->mfg);
			charger->alignment_capable = ALIGN_MFG_FAILED;
			goto align_end;
		}
		charger->alignment_capable = ALIGN_MFG_PASSED;
	}

	/* move to ALIGN_MFG_CHECKING or cache the value */
	if (!p9221_check_feature(charger, WLCF_DREAM_ALIGN))
		goto align_again;

	if (charger->pdata->alignment_scalar != 0) {
		res = charger->chip_get_iout(charger, &current_now);
		if (res != 0) {
			logbuffer_log(charger->log, "align: failed to read IOUT");
			current_now = 0;
		}

		current_filter_sample =
			charger->current_filtered / WLC_CURRENT_FILTER_LENGTH;

		if (charger->current_sample_cnt < WLC_CURRENT_FILTER_LENGTH)
			charger->current_sample_cnt++;
		else
			charger->current_filtered -= current_filter_sample;

		charger->current_filtered += (current_now / WLC_CURRENT_FILTER_LENGTH);
		if (charger->log_current_filtered)
			dev_info(&charger->client->dev, "current = %umA, avg_current = %umA\n",
				 current_now, charger->current_filtered);

		current_scaling = charger->pdata->alignment_scalar * charger->current_filtered;
	}

	if (charger->chip_id == P9221_CHIP_ID)
		p9221_align_check(charger, current_scaling);
	else
		p9xxx_align_check(charger);

align_again:
	/*
	 *  NOTE: mfg may be zero due to race condition during boot. If the
	 *  mfg check continues to fail then mfg is not correct and we do not
	 *  reschedule align_work. Always reschedule if alignment_capable is 1.
	 *  Check 10 times if alignment_capble is still 0.
	 */

	if ((charger->mfg_check_count < MFG_CHK_COUNT_MAX) ||
	    (charger->alignment_capable == ALIGN_MFG_PASSED)) {

		/* release the align_ws before return*/
		__pm_relax(charger->align_ws);

		schedule_delayed_work(&charger->align_work,
				      msecs_to_jiffies(P9221_ALIGN_DELAY_MS));

		return;
	}

align_end:

	/* release the align_ws */
	__pm_relax(charger->align_ws);

	dev_info(&charger->client->dev, "align_work ended(mfg_check_count=%d)\n",
		 charger->mfg_check_count);
}

static const char *p9221_get_tx_id_str(struct p9221_charger_data *charger)
{
	int ret;

	if (!p9221_is_online(charger))
		return NULL;

	pm_runtime_get_sync(charger->dev);
	if (!charger->resume_complete) {
		pm_runtime_put_sync(charger->dev);
		return NULL;
	}
	pm_runtime_put_sync(charger->dev);

	if (p9221_is_epp(charger)) {
		ret = p9xxx_chip_get_tx_id(charger, &charger->tx_id);
		if (ret && ret != -ENOTSUPP)
			dev_err(&charger->client->dev,
				"Failed to read txid %d\n", ret);
	} else {
		/*
		 * If pp_buf_valid is true, we have received a serial
		 * number from the Tx, copy it to tx_id. (pp_buf_valid
		 * is left true here until we go offline as we may
		 * read this multiple times.)
		 */
		if (charger->pp_buf_valid &&
		    sizeof(charger->tx_id) <= P9221R5_MAX_PP_BUF_SIZE)
			memcpy(&charger->tx_id, &charger->pp_buf[1],
			       sizeof(charger->tx_id));
	}
	scnprintf(charger->tx_id_str, sizeof(charger->tx_id_str),
		  "%08x", charger->tx_id);
	return charger->tx_id_str;
}

/* call holding mutex_lock(&chg_fts->feat_lock); */
static int feature_cache_lookup_by_id(struct p9221_charger_feature *chg_fts, u64 id)
{
	/* FIXME: lookup */
	struct p9221_charger_feature_entry *entry = &chg_fts->entries[0];
	int idx;

	for (idx = 0; idx < chg_fts->num_entries; idx++) {
		if (entry->quickid == id)
			break;

		entry++;
	}

	if (chg_fts->num_entries > 0 && idx < chg_fts->num_entries)
		return idx;
	else
		return -1;
}

/* call holding mutex_lock(&chg_fts->feat_lock); */
static void feature_update_cache(struct p9221_charger_feature *chg_fts,
				 u64 id, u64 ft)
{
	struct p9221_charger_feature_entry *entry = &chg_fts->entries[0];
	struct p9221_charger_feature_entry *oldest_entry;
	u32 oldest;
	int idx;

	chg_fts->age++;

	oldest = 0;
	oldest_entry = entry;

	/* TODO: reimplemente in terms of feature_cache_lookup_by_id() */
	for (idx = 0; idx < chg_fts->num_entries; idx++) {
		u32 age = chg_fts->age - entry->last_use;

		if (entry->quickid == id)
			goto store;

		if (age > oldest) {
			oldest_entry = entry;
			oldest = age;
		}
		entry++;
	}

	/* Not found, space still left, entry points to free spot. */
	if (idx < P9XXX_CHARGER_FEATURE_CACHE_SIZE)
		chg_fts->num_entries++;
	else
		entry = oldest_entry;

store:
	pr_debug("%s: tx_id=%llx, ft=%llx\n", __func__, id, ft);

	entry->quickid = id;
	entry->features = ft;
	entry->last_use = chg_fts->age;
	if (entry->features == 0)
		entry->last_use = 0;
}

static bool feature_cache_update_entry(struct p9221_charger_feature *chg_fts,
				       u64 id, u64 mask, u64 ft)
{
	struct p9221_charger_feature_entry *entry = &chg_fts->entries[0];
	bool updated = false;
	int index;

	mutex_lock(&chg_fts->feat_lock);

	index = feature_cache_lookup_by_id(chg_fts, id);
	if (index < 0) {
		/* add the new tx_id with ft to the feature cache */
		feature_update_cache(chg_fts, id, ft);
		updated = true;
		goto done_unlock;
	}

	pr_debug("%s: tx_id=%llx, mask=%llx ft=%llx\n", __func__, id, mask, ft);

	/* update the features using mask and ft */
	entry = &chg_fts->entries[index];
	if ((entry->features & mask) != ft) {
		entry->features |= (mask & ft);
		updated = true;
	}

	/* return true when features for id were actually updated  */
done_unlock:
	mutex_unlock(&chg_fts->feat_lock);
	return updated;
}

/* call holding mutex_lock(&chg_fts->feat_lock); */
static bool feature_cache_lookup_entry(struct p9221_charger_feature *chg_fts,
				       u64 id, u64 mask, u64 ft)
{
	struct p9221_charger_feature_entry *entry = &chg_fts->entries[0];
	int index;

	/* lookup id, true if found and feature&mask matches. */
	index = feature_cache_lookup_by_id(chg_fts, id);
	if (index >= 0) {
		entry = &chg_fts->entries[index];
		if ((entry->features & mask) == ft)
			return true;
	}

	return false;
}

/* call holding mutex_lock(&chg_fts->feat_lock); */
static bool feature_is_enabled(struct p9221_charger_feature *chg_fts,
			       u64 id, u64 ft)
{
	bool enabled = false;

	mutex_lock(&chg_fts->feat_lock);

	if (id)
		enabled = feature_cache_lookup_entry(chg_fts, id, ft, ft);
	if (!enabled)
		enabled = (chg_fts->session_features & ft) != 0;

	mutex_unlock(&chg_fts->feat_lock);

	return enabled;
}

static bool p9221_check_feature(struct p9221_charger_data *charger, u64 ft)
{
	struct p9221_charger_feature *chg_fts = &charger->chg_features;
	const bool feat_compat_mode = charger->pdata->feat_compat_mode;
	bool supported = false;
	u32 tx_id = 0;
	u8 val;

	/*  txid is available sometime after placing the device on the charger */
	if (p9221_get_tx_id_str(charger) != NULL)
		tx_id = charger->tx_id;

	/* tx_ix = 0 will check only the session features */
	supported = feature_is_enabled(chg_fts, tx_id, ft);
	if (supported)
		return true;

	if (!supported && !feat_compat_mode)
		return false;

	/* compat mode until the features API is usedm check txid */
	val = (tx_id & TXID_TYPE_MASK) >> TXID_TYPE_SHIFT;
	if (val == TXID_DD_TYPE || val == TXID_DD_TYPE2)
		supported = true;

	/* NOTE: some features need to be tied to mfgid */
	if (supported && charger->pdata->feat_compat_mode) {
		bool updated;

		updated = feature_cache_update_entry(chg_fts, tx_id, ft, ft);
		if (updated)
			pr_debug("%s: tx_id=%x, ft=%llx supported=%d\n", __func__,
				  tx_id, ft, supported);
	}

	return supported;
}


static int p9382_get_ptmc_id_str(char *buffer, int len,
				 struct p9221_charger_data *charger)
{
	int ret;
	uint16_t ptmc_id;

	if (!p9221_is_online(charger))
		return -ENODEV;

	pm_runtime_get_sync(charger->dev);
	if (!charger->resume_complete) {
		pm_runtime_put_sync(charger->dev);
		return -EAGAIN;
	}
	pm_runtime_put_sync(charger->dev);

	ret = p9xxx_chip_get_tx_mfg_code(charger, &ptmc_id);
	if (ret) {
		dev_err(&charger->client->dev,
			"Failed to read device prmc %d\n", ret);
		return ret;
	}

	return scnprintf(buffer, len, "%04x", ptmc_id);
}

/*
 * DC_SUSPEND is used to prevent inflow from wireless charging. When present
 * will return 1 if the user has disabled the source (override online).
 */
static int p9221_get_psy_online(struct p9221_charger_data *charger)
{
	int suspend = -EINVAL;

	if (!charger->dc_suspend_votable)
		charger->dc_suspend_votable =
			gvotable_election_get_handle("DC_SUSPEND");
	if (charger->dc_suspend_votable)
		suspend = gvotable_get_current_int_vote(
				charger->dc_suspend_votable);

	/* TODO: not sure if this needs to be reported */
	if (suspend < 0)
		return suspend;
	if (suspend || !charger->online || !charger->enabled)
		return 0;

	return charger->wlc_dc_enabled ? PPS_PSY_PROG_ONLINE : 1;
}

static int p9221_has_dc_in(struct p9221_charger_data *charger)
{
	union power_supply_propval prop;
	int ret;

	if (!charger->dc_psy)
		charger->dc_psy = power_supply_get_by_name("dc");
	if (!charger->dc_psy)
		return -EINVAL;

	ret = power_supply_get_property(charger->dc_psy,
					POWER_SUPPLY_PROP_PRESENT, &prop);
	if (ret < 0) {
		dev_err(&charger->client->dev,
			"Error getting charging status: %d\n", ret);
		return -EINVAL;
	}

	return prop.intval != 0;
}

static void p9221_charge_stats_init(struct p9221_charge_stats *chg_data)
{
	memset(chg_data, 0, sizeof(struct p9221_charge_stats));
	chg_data->cur_soc = -1;
}

static int p9221_stats_init_capabilities(struct p9221_charger_data *charger)
{
	struct p9221_charge_stats *chg_data = &charger->chg_data;
	const u8 ac_ver = 0;
	const u8 flags = 0;
	u8 sys_mode = 0;
	u16 ptmc_id = 0;
	int ret = 0;

	ret = p9xxx_chip_get_tx_mfg_code(charger, &ptmc_id);
	ret |= charger->chip_get_sys_mode(charger, &sys_mode);

	chg_data->adapter_capabilities[0] = flags << 8 | ac_ver;
	chg_data->adapter_capabilities[1] = ptmc_id;

	chg_data->receiver_state[0] = sys_mode;

	return ret ? -EIO : 0;
}

static int p9221_stats_update_state(struct p9221_charger_data *charger)
{
	struct p9221_charge_stats *chg_data = &charger->chg_data;
	u8 flags = 0;

	flags |= charger->prop_mode_en << 0;
	flags |= charger->is_mfg_google << 1;
	flags |= charger->wlc_dc_enabled << 2;

	chg_data->adapter_capabilities[0] |= flags << 8;

	return 0;
}

static void p9221_update_head_stats(struct p9221_charger_data *charger)
{
	u32 vout_mv, iout_ma;
	u32 wlc_freq = 0;
	u8 sys_mode;
	int ret;

	ret = charger->chip_get_sys_mode(charger, &sys_mode);
	if (ret != 0)
		return;

	charger->chg_data.adapter_type = sys_mode;

	ret = charger->chip_get_op_freq(charger, &wlc_freq);
	if (ret != 0)
		wlc_freq = -1;

	charger->chg_data.of_freq = wlc_freq;

	if (charger->wlc_dc_enabled) {
		ret = charger->chip_get_rx_ilim(charger, &iout_ma);
		if (ret)
			iout_ma = 0;
	} else if (!charger->dc_icl_votable) {
		iout_ma = 0;
	} else {
		int iout_ua;

		/* the unit charger->dc_icl_votable is uA, need to change to mA */
		iout_ua =
			gvotable_get_current_int_vote(charger->dc_icl_votable);
		if (iout_ua < 0)
			iout_ma = 0;
		else
			iout_ma = iout_ua / 1000;
	}
	charger->chg_data.cur_conf = iout_ma;

	if (charger->wlc_dc_enabled) {
		vout_mv = charger->pdata->max_vout_mv;
	} else if (p9221_ready_to_read(charger) < 0) {
		vout_mv = 0;
	} else {
		ret = charger->chip_get_vout_max(charger, &vout_mv);
		if (ret)
			vout_mv = 0;
	}
	charger->chg_data.volt_conf = vout_mv;
}

static void p9221_update_soc_stats(struct p9221_charger_data *charger,
				   int cur_soc)
{
	const ktime_t now = get_boot_sec();
	struct p9221_soc_data *soc_data;
	u32 vrect_mv, iout_ma, cur_pout;
	int ret, temp, interval_time = 0;
	u32 wlc_freq = 0;
	u8 sys_mode;

	ret = charger->chip_get_sys_mode(charger, &sys_mode);
	if (ret != 0)
		return;

	ret = charger->chip_get_op_freq(charger, &wlc_freq);
	if (ret != 0)
		wlc_freq = -1;

	ret = charger->chip_get_die_temp(charger, &temp);
	if (ret == 0)
		temp = P9221_MILLIC_TO_DECIC(temp);
	else
		temp = -1;

	ret = charger->chip_get_vrect(charger, &vrect_mv);
	if (ret != 0)
		vrect_mv = 0;

	ret = charger->chip_get_iout(charger, &iout_ma);
	if (ret != 0)
		iout_ma = 0;

	soc_data = &charger->chg_data.soc_data[cur_soc];

	soc_data->vrect = vrect_mv;
	soc_data->iout = iout_ma;
	soc_data->sys_mode = sys_mode;
	soc_data->die_temp = temp;
	soc_data->of_freq = wlc_freq;
	soc_data->alignment = charger->alignment;

	cur_pout = vrect_mv * iout_ma;
	if ((soc_data->pout_min == 0) || (soc_data->pout_min > cur_pout))
		soc_data->pout_min = cur_pout;
	if ((soc_data->pout_max == 0) || (soc_data->pout_max < cur_pout))
		soc_data->pout_max = cur_pout;

	if (soc_data->last_update != 0)
		interval_time = now - soc_data->last_update;

	soc_data->elapsed_time += interval_time;
	soc_data->pout_sum += cur_pout * interval_time;
	soc_data->last_update = now;
}

static void p9221_check_adapter_type(struct p9221_charger_data *charger)
{
	/*  txid is available sometime after placing the device on the charger */
	if (p9221_get_tx_id_str(charger) != NULL) {
		u8 id_type = (charger->tx_id & TXID_TYPE_MASK) >> TXID_TYPE_SHIFT;

		if (id_type != charger->chg_data.adapter_type)
			pr_debug("%s: tx_id=%08x, adapter_type=%x->%x\n", __func__,
				 charger->tx_id, charger->chg_data.adapter_type,
				 id_type);

		charger->chg_data.adapter_type = id_type;
	}
}

static int p9221_chg_data_head_dump(char *buff, int max_size,
				    const struct p9221_charge_stats *chg_data)
{
	return scnprintf(buff, max_size, "A:%d,%d,%d,%d,%d",
			 chg_data->adapter_type, chg_data->cur_soc,
			 chg_data->volt_conf, chg_data->cur_conf,
			 chg_data->of_freq);
}

static int p9221_adapter_capabilities_dump(char *buff, int max_size,
					   const struct p9221_charge_stats *chg_data)
{
	return scnprintf(buff, max_size, "D:%x,%x,%x,%x,%x, %x,%x",
			 chg_data->adapter_capabilities[0],
			 chg_data->adapter_capabilities[1],
			 chg_data->adapter_capabilities[2],
			 chg_data->adapter_capabilities[3],
			 chg_data->adapter_capabilities[4],
			 chg_data->receiver_state[0],
			 chg_data->receiver_state[1]);
}

static int p9221_soc_data_dump(char *buff, int max_size,
			       const struct p9221_charge_stats *chg_data,
			       int index)
{
	return scnprintf(buff, max_size, "%d:%d, %d,%ld,%d, %d,%d, %d,%d,%d,%d",
			 index,
			 chg_data->soc_data[index].elapsed_time,
			 chg_data->soc_data[index].pout_min / 100000,
			 chg_data->soc_data[index].pout_sum /
			 chg_data->soc_data[index].elapsed_time/ 100000,
			 chg_data->soc_data[index].pout_max / 100000,
			 chg_data->soc_data[index].of_freq,
			 chg_data->soc_data[index].alignment,
			 chg_data->soc_data[index].vrect,
			 chg_data->soc_data[index].iout,
			 chg_data->soc_data[index].die_temp,
			 chg_data->soc_data[index].sys_mode);
}

/* needs mutex_lock(&charger->stats_lock); */
static void p9221_dump_charge_stats(struct p9221_charger_data *charger)
{
	char buff[128];
	int i = 0;

	if (charger->chg_data.cur_soc < 0)
		return;

	/* Dump the head */
	p9221_chg_data_head_dump(buff, sizeof(buff), &charger->chg_data);
	logbuffer_log(charger->log, "%s", buff);

	/* Dump the adapter capabilities */
	p9221_adapter_capabilities_dump(buff, sizeof(buff), &charger->chg_data);
	logbuffer_log(charger->log, "%s", buff);


	for (i = 0; i < WLC_SOC_STATS_LEN; i++) {
		if (charger->chg_data.soc_data[i].elapsed_time == 0)
			continue;
		p9221_soc_data_dump(buff, sizeof(buff), &charger->chg_data, i);
		logbuffer_log(charger->log, "%s", buff);
	}
}

static int p9221_get_property(struct power_supply *psy,
			      enum power_supply_property prop,
			      union power_supply_propval *val)
{
	struct p9221_charger_data *charger = power_supply_get_drvdata(psy);
	int rc, ret = 0;
	u32 temp;

	switch (prop) {
	/* check for field */
	case POWER_SUPPLY_PROP_PRESENT:
		val->intval = p9221_has_dc_in(charger);
		if (val->intval < 0)
			val->intval = 0;
		break;
	case POWER_SUPPLY_PROP_ONLINE:
		if (charger->wait_for_online) {
			val->intval = 1;
			break;
		}

		val->intval = p9221_get_psy_online(charger);
		break;
	case POWER_SUPPLY_PROP_SERIAL_NUMBER:
		val->strval = p9221_get_tx_id_str(charger);
		if (val->strval == NULL)
			return -ENODATA;
		break;
	case POWER_SUPPLY_PROP_CAPACITY:
		/* Zero may be returned on transition to wireless "online", as
		 * last_capacity is reset to -1 until capacity is re-written
		 * from userspace, leading to a new csp packet being sent.
		 *
		 * b/80435107 for additional context
		 */
		if (charger->last_capacity > 0)
			val->intval = charger->last_capacity;
		else
			val->intval = 0;
		break;
	case POWER_SUPPLY_PROP_CURRENT_MAX:
		if (charger->wlc_dc_enabled) {
			rc = charger->chip_get_rx_ilim(charger, &temp);
			if (rc == 0)
				charger->wlc_dc_current_now = temp * 1000; /* mA to uA */

			val->intval = rc ? : charger->wlc_dc_current_now;
		} else {
			if (!charger->dc_icl_votable)
				return -EAGAIN;
			val->intval = gvotable_get_current_int_vote(
						charger->dc_icl_votable);
		}
		break;
#ifdef CONFIG_QC_COMPAT
	case POWER_SUPPLY_PROP_AICL_DELAY:
		val->intval = charger->aicl_delay_ms;
		break;
	case POWER_SUPPLY_PROP_AICL_ICL:
		val->intval = charger->aicl_icl_ua;
		break;
#endif
	case POWER_SUPPLY_PROP_CURRENT_NOW:
		rc = p9221_ready_to_read(charger);
		if (rc < 0) {
			val->intval = 0;
		} else {
			rc = charger->chip_get_iout(charger, &temp);
			if (charger->wlc_dc_enabled && (rc == 0))
				charger->wlc_dc_current_now = temp * 1000; /* mA to uA */

			val->intval = rc ? : temp * 1000; /* mA to uA */
		}
		break;

	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		rc = p9221_ready_to_read(charger);
		if (rc < 0) {
			val->intval = 0;
		} else if (charger->wlc_dc_enabled) {
			rc = charger->chip_get_vout(charger, &temp);
			if (rc == 0)
				charger->wlc_dc_voltage_now = temp * 1000; /* mV to uV */
		} else {
			rc = charger->chip_get_vout(charger, &temp);
		}

		val->intval = rc ? : temp * 1000; /* mV to uV */
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
		if (charger->wlc_dc_enabled) {
			val->intval = charger->pdata->max_vout_mv * 1000; /* mV to uV */
		} else {
			rc = p9221_ready_to_read(charger);
			if (rc < 0) {
				val->intval = 0;
			} else {
				u32 mv;

				rc = charger->chip_get_vout_max(charger, &mv);
				if (rc)
					val->intval = rc;
				else
					val->intval = mv * 1000; /* mv to uV */
			}
		}
		break;

	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
		val->intval = 5000000; // TODO: fix it
		break;
	case POWER_SUPPLY_PROP_TEMP:
		rc = p9221_ready_to_read(charger);
		if (!rc) {
			rc = charger->chip_get_die_temp(charger, &val->intval);
			if (!rc)
				val->intval = P9221_MILLIC_TO_DECIC(val->intval);
		}

		if (rc)
			val->intval = rc;
		break;

	default:
		ret = -EINVAL;
		break;
	}

	if (ret)
		dev_dbg(&charger->client->dev,
			"Couldn't get prop %d, ret=%d\n", prop, ret);
	return ret;
}

#define P9221_CHARGE_STATS_DELAY_SEC 10
static void p9221_charge_stats_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, charge_stats_work.work);
	struct p9221_charge_stats *chg_data = &charger->chg_data;
	const ktime_t now = get_boot_sec();
	const ktime_t start_time = chg_data->start_time;
	const ktime_t elap = now - chg_data->start_time;

	mutex_lock(&charger->stats_lock);

	if (charger->online == 0 || charger->last_capacity < 0 || charger->last_capacity > 100)
		goto unlock_done;

	/* Charge_stats buffer is Empty */
	if (chg_data->cur_soc < 0) {
		/* update the head */
		chg_data->cur_soc = charger->last_capacity;
		chg_data->last_soc = charger->last_capacity;
		p9221_update_head_stats(charger);
		chg_data->start_time = get_boot_sec();
	} else if (start_time && elap > P9221_CHARGE_STATS_DELAY_SEC) {
		/*
		 * Voltage, Current and sys_mode are not correct
		 * on wlc start. Debounce by 10 seconds.
		 */
		p9221_update_head_stats(charger);
		p9221_stats_init_capabilities(charger);
		chg_data->start_time = 0;
	}

	p9221_check_adapter_type(charger);
	p9221_stats_update_state(charger);

	/* SOC changed, store data to the last one. */
	if (chg_data->last_soc != charger->last_capacity)
		p9221_update_soc_stats(charger, chg_data->last_soc);
	/* update currect_soc data */
	p9221_update_soc_stats(charger, charger->last_capacity);

	chg_data->last_soc = charger->last_capacity;

	schedule_delayed_work(&charger->charge_stats_work,
			      msecs_to_jiffies(P9221_CHARGE_STATS_TIMEOUT_MS));

unlock_done:
	mutex_unlock(&charger->stats_lock);
}

static bool p9412_is_calibration_done(struct p9221_charger_data *charger)
{
	u8 reg;
	int ret;

	ret = p9221_reg_read_8(charger, P9412_EPP_CAL_STATE_REG, &reg);

	dev_info(&charger->client->dev, "EPP_CAL_STATE_REG=%02x\n", reg);

	return ((ret == 0) && ((reg & P9412_EPP_CAL_STATE_MASK) == 0));
}

static bool feature_check_fast_charge(struct p9221_charger_data *charger)
{
	struct p9221_charger_feature *chg_fts = &charger->chg_features;
	bool enabled;

	/* ignore the feature in compatibility until the first vote */
	if (charger->pdata->feat_compat_mode) {
		pr_debug("%s: COMPAT FAST_CHARGE ENABLED\n", __func__);
		return true;
	}

	enabled = feature_is_enabled(chg_fts, 0, WLCF_FAST_CHARGE);
	if (enabled)
		pr_debug("%s: feature enabled=%d\n", __func__, enabled);

	return enabled;
}

static int p9221_set_hpp_dc_icl(struct p9221_charger_data *charger, bool enable)
{
	int ret;

	if (!charger->dc_icl_votable)
		return 0;

	if (charger->pdata->has_sw_ramp && enable) {
		dev_dbg(&charger->client->dev, "%s: voter=%s, icl=%d\n",
			__func__, HPP_DC_ICL_VOTER, P9221_DC_ICL_HPP_UA);
		ret = p9xxx_sw_ramp_icl(charger, P9221_DC_ICL_HPP_UA);
		if (ret == 0)
			ret = gvotable_cast_long_vote(charger->dc_icl_votable,
						      HPP_DC_ICL_VOTER,
						      P9221_DC_ICL_HPP_UA,
						      enable);
		if (ret == 0)
			ret = gvotable_cast_int_vote(charger->dc_icl_votable,
						     P9221_RAMP_VOTER, 0, false);
		return ret;
	}

	return gvotable_cast_long_vote(charger->dc_icl_votable,
				       HPP_DC_ICL_VOTER,
				       enable ? P9221_DC_ICL_HPP_UA : 0,
				       enable);
}

/*
 * Auth delay must be there for EPP until the timeout since we don't know
 * if the TX supports WPC1.3 Auth until the timeout expires (or until
 * set features tell us the auth limit is not needed anymore)
 * hold mutex_lock(&charger->auth_lock);
 */
int p9221_set_auth_dc_icl(struct p9221_charger_data *charger, bool enable)
{
	int ret = 0, icl_ua;

	icl_ua = enable ? P9221_AUTH_DC_ICL_UA_500 : 0;

	if (!charger->dc_icl_votable)
		goto exit;

	if (enable && !charger->auth_delay) {
		dev_info(&charger->client->dev, "Enable Auth ICL (%d)\n", ret);
		charger->auth_delay = true;
	} else if (!enable) {
		dev_info(&charger->client->dev, "Disable Auth ICL (%d)\n", ret);
		charger->auth_delay = false;
		cancel_delayed_work(&charger->auth_dc_icl_work);
		alarm_try_to_cancel(&charger->auth_dc_icl_alarm);
	}

	ret = gvotable_cast_int_vote(charger->dc_icl_votable, AUTH_DC_ICL_VOTER,
				     icl_ua, enable);
	if (ret < 0)
		goto exit;

	if (!charger->csi_status_votable)
		charger->csi_status_votable =
				gvotable_election_get_handle(VOTABLE_CSI_STATUS);
	if (charger->csi_status_votable)
		gvotable_cast_long_vote(charger->csi_status_votable,
					"CSI_STATUS_ADA_AUTH",
					CSI_STATUS_Adapter_Auth,
					charger->auth_delay);

exit:
	return ret;
}

static int p9xxx_check_alignment(struct p9221_charger_data *charger)
{
	int ret = 0;

	if (charger->alignment == 100) {
		dev_dbg(&charger->client->dev, "Alignment check OK\n");
	} else if (charger->alignment == -1 && charger->mfg_check_count < MFG_CHK_COUNT_MAX) {
		ret = -EAGAIN;
		dev_dbg(&charger->client->dev, "Alignment checking\n");
	} else {
		ret = -EOPNOTSUPP;
		dev_err(&charger->client->dev, "Misalignment!\n");
	}

	return ret;
}

/* < 0 error, 0 = no changes, > 1 changed */
static int p9221_set_psy_online(struct p9221_charger_data *charger, int online)
{
	const bool wlc_dc_enabled = charger->wlc_dc_enabled;
	const bool enabled = charger->enabled;
	int ret;

	if (online < 0 || online > PPS_PSY_PROG_ONLINE)
		return -EINVAL;

	/* online = 2 enable LL, return < 0 if NOT on LL */
	if (online == PPS_PSY_PROG_ONLINE) {
		const int extben_gpio = charger->pdata->ext_ben_gpio;
		bool feat_enable;
		u8 val8;

		pr_info("%s: online=%d, enabled=%d wlc_dc_enabled=%d prop_mode_en=%d\n",
			__func__, online, enabled, wlc_dc_enabled,
			charger->prop_mode_en);

		if (!enabled) {
			dev_warn(&charger->client->dev,
				 "Cannot send PROG with enable=%d, wlc_dc_enabled=%d\n",
				 enabled, wlc_dc_enabled);
			if (wlc_dc_enabled)
				p9221_reset_wlc_dc(charger);
			return -EINVAL;
		}

		/* Ping? */
		if (wlc_dc_enabled) {
			/* TODO: disable fast charge if enabled */
			feat_enable = feature_check_fast_charge(charger);
			if (feat_enable == 0)
				pr_debug("%s: FAST_CHARGE disabled\n", __func__);

			return 0;
		}

		/* not there, must return not supp */
		if (!charger->pdata->has_wlc_dc || !p9221_is_online(charger)
		    || !p9221_is_epp(charger))
			return -EOPNOTSUPP;

		if (charger->last_capacity > WLC_HPP_SOC_LIMIT)
			return -EOPNOTSUPP;

		/* need to check calibration is done before re-negotiate */
		if (!p9412_is_calibration_done(charger)) {
			dev_warn(&charger->client->dev, "Calibrating\n");
			return -EAGAIN;
		}

		ret = charger->reg_read_8(charger, P9221R5_EPP_TX_GUARANTEED_POWER_REG, &val8);
		if (ret < 0)
			return -EINVAL;
		if (val8 < P9XXX_TX_GUAR_PWR_15W) {
			dev_warn(&charger->client->dev, "Tx guar_pwr=%dW\n", val8 / 2);
			p9221_set_auth_dc_icl(charger, false);
			return -EOPNOTSUPP;
		}

		/* will return -EAGAIN until the feature is supported */
		mutex_lock(&charger->auth_lock);

		feat_enable = feature_check_fast_charge(charger);
		if (feat_enable) {
			pr_debug("%s: Feature check OK\n", __func__);
		} else if (charger->auth_delay) {
			mutex_unlock(&charger->auth_lock);
			return -EAGAIN;
		} else {
			dev_warn(&charger->client->dev, "Feature check failed\n");
			p9221_set_auth_dc_icl(charger, false);
			mutex_unlock(&charger->auth_lock);
			return -EOPNOTSUPP;
		}

		/* AUTH is passed remove the DC_ICL limit */
		p9221_set_auth_dc_icl(charger, false);
		mutex_unlock(&charger->auth_lock);

		/* Check alignment before enabling proprietary mode */
		ret = p9xxx_check_alignment(charger);
		if (ret < 0)
			return ret;

		ret = p9221_set_hpp_dc_icl(charger, true);
		if (ret < 0)
			dev_warn(&charger->client->dev, "Cannot enable HPP_ICL (%d)\n", ret);
		mdelay(10);

		/*
		 * run ->chip_prop_mode_en() if proprietary mode or cap divider
		 * mode isn't enabled (i.e. with p9412_prop_mode_enable())
		 */
		if (!(charger->prop_mode_en && p9xxx_is_capdiv_en(charger))) {
			ret = set_renego_state(charger, P9XXX_ENABLE_PROPMODE);
			if (ret == -EAGAIN)
				return ret;
			ret = charger->chip_prop_mode_en(charger, HPP_MODE_PWR_REQUIRE);
			if (ret == -EAGAIN) {
				dev_warn(&charger->client->dev, "PROP Mode retry\n");
				return ret;
			}
			set_renego_state(charger, P9XXX_AVAILABLE);
		}

		if (!(charger->prop_mode_en && p9xxx_is_capdiv_en(charger))) {
			ret = charger->chip_capdiv_en(charger, CDMODE_BYPASS_MODE);
			if (ret < 0)
				dev_warn(&charger->client->dev,
					 "Cannot change to bypass mode (%d)\n", ret);
			ret = p9221_set_hpp_dc_icl(charger, false);
			if (ret < 0)
				dev_warn(&charger->client->dev,
					 "Cannot disable HPP_ICL (%d)\n", ret);
			ret = gvotable_cast_int_vote(charger->dc_icl_votable,
					P9221_HPP_VOTER, 0, false);
			if (ret < 0)
				dev_warn(&charger->client->dev,
					 "Cannot disable HPP_VOTER (%d)\n", ret);

			pr_debug("%s: HPP not supported\n", __func__);
			return -EOPNOTSUPP;
		}

		p9221_write_fod(charger);

		charger->wlc_dc_enabled = true;
		if (extben_gpio)
			p9xxx_gpio_set_value(charger, extben_gpio, 1);

		p9221_set_switch_reg(charger, true);

		/* Adjusting the minimum on time(MOT) for mitigate LC node voltage overshoot */
		ret = p9221_reg_write_8(charger, P9412_MOT_REG, P9412_MOT_40PCT);
		if (ret < 0)
			dev_warn(&charger->client->dev, "Fail to adjust MOT(%d)\n", ret);

		return 1;
	} else if (wlc_dc_enabled) {
		/* TODO: thermals might come in and disable with 0 */
		p9221_reset_wlc_dc(charger);
	}

	/*
	 * Asserting the enable line will automatically take bring
	 * us online if we are in field.  De-asserting the enable
	 * line will automatically take us offline if we are in field.
	 * This is due to the fact that DC in will change state
	 * appropriately when we change the state of this line.
	 */
	charger->enabled = !!online;

	ret = p9221_set_hpp_dc_icl(charger, false);
	if (ret < 0)
		dev_warn(&charger->client->dev, "Cannot disable HPP_ICL (%d)\n", ret);

	gvotable_cast_int_vote(charger->dc_icl_votable,
				P9221_HPP_VOTER, 0, false);

	dev_warn(&charger->client->dev, "Set enable %d, wlc_dc_enabled:%d->%d\n",
		charger->enabled, wlc_dc_enabled, charger->wlc_dc_enabled);

	gvotable_cast_bool_vote(charger->wlc_disable_votable,
				P9221_WLC_VOTER, !charger->enabled);

	return 1;
}

/* 400 seconds debounce for auth per WPC spec */
#define DREAM_DEBOUNCE_TIME_S 400

/* trigger DD */
static void p9221_dream_defend(struct p9221_charger_data *charger)
{
	const ktime_t now = get_boot_sec();
	u32 threshold;
	int ret;

	/* debounce for auth TODO: use charger->auth_delay */
	if (now - charger->online_at < DREAM_DEBOUNCE_TIME_S) {
		pr_debug("%s: now=%lld, online_at=%lld delta=%lld\n", __func__,
			 now, charger->online_at, now - charger->online_at);
		return;
	}

	threshold = charger->mitigate_threshold > 0 ? charger->mitigate_threshold :
		    charger->pdata->power_mitigate_threshold;
	if (!threshold)
		return;

	if (charger->last_capacity > threshold &&
		!charger->trigger_power_mitigation) {
		/*
		 * Check Tx type here as tx_id may not be ready at start
		 * and mfg code cannot be read after LL changing to BPP mode
		 */
		charger->ll_bpp_cep = p9221_ll_check_id(charger);
		/* trigger_power_mitigation is the same as dream defend */
		charger->trigger_power_mitigation = true;
		ret = delayed_work_pending(&charger->power_mitigation_work);
		if (!ret)
			schedule_delayed_work(&charger->power_mitigation_work,
			    msecs_to_jiffies(P9221_POWER_MITIGATE_DELAY_MS));
	}

}

static void p9221_ll_check_chg_term(struct p9221_charger_data *charger, int capacity)
{
	int ll_icl_ua;

	ll_icl_ua = gvotable_get_int_vote(charger->dc_icl_votable, LL_BPP_CEP_VOTER);

	if (capacity < 97) {
		if (ll_icl_ua == P9221_LL_BPP_CHG_TERM_UA)
			dev_info(&charger->client->dev, "power_mitigate: remove LL_BPP_CEP_VOTER(capacity=%d)\n",
				 capacity);
		gvotable_cast_int_vote(charger->dc_icl_votable, LL_BPP_CEP_VOTER, 0, false);
	} else if (capacity == 101) {
		/* when gdf==100, it's chg_term and vote 200mA */
		if (ll_icl_ua != P9221_LL_BPP_CHG_TERM_UA)
			dev_info(&charger->client->dev, "power_mitigate: LL_BPP vote DC_ICL=%duA(capacity=%d)\n",
				 P9221_LL_BPP_CHG_TERM_UA, capacity);
		gvotable_cast_int_vote(charger->dc_icl_votable, LL_BPP_CEP_VOTER,
				       P9221_LL_BPP_CHG_TERM_UA, true);
	}
}

/* improve LL BPP CEP_timeout */
static void p9221_ll_bpp_cep(struct p9221_charger_data *charger, int capacity)
{
	int icl_ua = 0;

	if (capacity > 94)
		icl_ua = 750000;
	if (capacity > 96)
		icl_ua = 600000;
	if (capacity > 98)
		icl_ua = 300000;

	gvotable_cast_int_vote(charger->dc_icl_votable,
			       DD_VOTER, icl_ua, icl_ua > 0);

	p9221_ll_check_chg_term(charger, capacity);

	if (icl_ua > 0)
		dev_dbg(&charger->client->dev,
			"power_mitigate: DD vote ICL = %duA\n",
			gvotable_get_int_vote(charger->dc_icl_votable, DD_VOTER));
}

/*
 * identify TXID_DD_TYPE2 checking PTCPM and ID
 * return -EAGAIN until the id is available, 0 on non match
 */
static int p9221_ll_check_id(struct p9221_charger_data *charger)
{
	uint16_t ptmc_id = charger->mfg;
	int ret;

	/*
	 * TODO: this returns 0 on 3rd party. Solve by debounce changes of
	 * last_capacity for some time after online and/or adding a robust
	 * way to detect if the device is actuall on a pad that needs the
	 * WAR and behaviors controlled by this check.
	 */
	if (ptmc_id == 0) {
		ret = p9xxx_chip_get_tx_mfg_code(charger, &ptmc_id);
		if (ret < 0 || ptmc_id == 0) {
			pr_debug("%s: cannot get mfg code ptmc_id=%x (%d)\n",
				 __func__, ptmc_id, ret);
			return -EAGAIN;
		}
	}

	if (ptmc_id != WLC_MFG_GOOGLE) {
		pr_debug("%s: ptmc_id=%x\n", __func__, ptmc_id);
		return 0;
	}

	/* NOTE: will keep the alternate limit and keep checking on 3rd party */
	if (p9221_get_tx_id_str(charger) == NULL) {
		pr_debug("%s: retry %x\n", __func__, charger->tx_id);
		return -EAGAIN;
	}

	/* optional check for P9221R5_EPP_TX_GUARANTEED_POWER_REG == 0x1e */

	pr_debug("%s: tx_ix=%08x\n", __func__, charger->tx_id);
	return ((charger->tx_id & TXID_TYPE_MASK) >> TXID_TYPE_SHIFT) == TXID_DD_TYPE2;
}

static void p9221_set_capacity(struct p9221_charger_data *charger, int capacity)
{
	int ret, capacity_raw = capacity;

	mutex_lock(&charger->stats_lock);

	if (charger->last_capacity == capacity &&
		(capacity != 100 || !p9221_is_epp(charger)))
		goto unlock_done;

	charger->last_capacity = (capacity <= 100) ? capacity : 100;

	if (!p9221_is_online(charger))
		goto unlock_done;

	ret = p9221_send_csp(charger, charger->last_capacity);
	if (ret)
		dev_err(&charger->client->dev, "Could not send csp: %d\n", ret);

	/* p9221_is_online() is true when the device in TX mode. */
	if (charger->online && charger->last_capacity >= 0 && charger->last_capacity <= 100)
		mod_delayed_work(system_wq, &charger->charge_stats_work, 0);

	if (charger->online && p9221_is_epp(charger))
		p9221_dream_defend(charger);

	/* CEP LL workaround tp improve comms */
	if (charger->ll_bpp_cep == 1 && !p9221_is_epp(charger))
		p9221_ll_bpp_cep(charger, capacity_raw);

unlock_done:
	mutex_unlock(&charger->stats_lock);
}

static int p9221_set_property(struct power_supply *psy,
			      enum power_supply_property prop,
			      const union power_supply_propval *val)
{
	struct p9221_charger_data *charger = power_supply_get_drvdata(psy);
	bool changed = false;
	int rc, ret = 0;

	switch (prop) {
	case POWER_SUPPLY_PROP_ONLINE:
		rc = p9221_set_psy_online(charger, val->intval);
		if (rc < 0) {
			ret = rc;
			break;
		}
		changed = !!rc;
		break;
	case POWER_SUPPLY_PROP_CAPACITY: {
		int capacity = val->intval;

		/* TODO: ignore the direct calls when fuel-gauge is defined */
		if (charger->fg_psy && (capacity != 101)) {
			union power_supply_propval prop;

			rc = power_supply_get_property(charger->fg_psy,
					POWER_SUPPLY_PROP_CAPACITY, &prop);
			if (rc == 0 && capacity != prop.intval) {
				pr_debug("%s: orig=%d new=%d\n", __func__,
					 val->intval, prop.intval);
				capacity = prop.intval;
			}
		}

		p9221_set_capacity(charger, capacity);
		break;
	}
	case POWER_SUPPLY_PROP_CURRENT_MAX:
		if (val->intval < 0) {
			ret = -EINVAL;
			break;
		}

		if (!charger->dc_icl_votable) {
			ret = -EAGAIN;
			break;
		}

		ret = gvotable_cast_int_vote(charger->dc_icl_votable,
					     P9221_USER_VOTER,
					     val->intval, true);
		changed = true;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
		ret = charger->chip_set_vout_max(charger, P9221_UV_TO_MV(val->intval));
		/* this is extra, please verify */
		if (ret == 0)
			changed = true;
		break;

	/* route to p9412 if for wlc_dc */
	case POWER_SUPPLY_PROP_CURRENT_NOW:
		if (!charger->wlc_dc_enabled) {
			dev_dbg(&charger->client->dev,
				"Not WLC-DC, not allow to set dc current\n");
			ret = -EINVAL;
			break;
		}
		/* uA */
		charger->wlc_dc_current_now = val->intval;
		ret = charger->chip_set_rx_ilim(charger, P9221_UA_TO_MA(charger->wlc_dc_current_now));
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		if (!charger->wlc_dc_enabled) {
			dev_dbg(&charger->client->dev,
				"Not WLC-DC, not allow to set Vout\n");
			ret = -EINVAL;
			break;
		}
		/* uV */
		charger->wlc_dc_voltage_now = val->intval;
		ret = charger->chip_set_vout_max(charger, P9221_UV_TO_MV(charger->wlc_dc_voltage_now));
		charger->hpp_hv = (ret == 0 &&
				   charger->wlc_dc_voltage_now > HPP_FOD_VOUT_THRESHOLD_UV);
		p9221_write_fod(charger);
		break;

	default:
		return -EINVAL;
	}

	if (ret)
		dev_dbg(&charger->client->dev,
			"Couldn't set prop %d, ret=%d\n", prop, ret);

	if (changed)
		power_supply_changed(psy);

	return ret;
}

static int p9221_prop_is_writeable(struct power_supply *psy,
				   enum power_supply_property prop)
{
	int writeable = 0;

	switch (prop) {
	case POWER_SUPPLY_PROP_CURRENT_MAX:
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
	case POWER_SUPPLY_PROP_CAPACITY:
	case POWER_SUPPLY_PROP_ONLINE:
	case POWER_SUPPLY_PROP_CURRENT_NOW:
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		writeable = 1;
		break;
	default:
		break;
	}

	return writeable;
}

static int p9221_notifier_cb(struct notifier_block *nb, unsigned long event,
			     void *data)
{
	struct power_supply *psy = data;
	struct p9221_charger_data *charger =
		container_of(nb, struct p9221_charger_data, nb);
	const char *fg_name = IS_ERR_OR_NULL(charger->fg_psy) || !charger->fg_psy->desc ?
			      NULL : charger->fg_psy->desc->name;

	if (charger->ben_state)
		goto out;

	if (event != PSY_EVENT_PROP_CHANGED)
		goto out;

	if (strcmp(psy->desc->name, "dc") == 0) {
		charger->dc_psy = psy;
		charger->check_dc = true;
	} else if (fg_name && strcmp(psy->desc->name, fg_name) == 0) {
		schedule_delayed_work(&charger->fg_work, 0);
	}

	if (!charger->check_dc)
		goto out;

	pm_stay_awake(charger->dev);

	if (!schedule_delayed_work(&charger->notifier_work,
				   msecs_to_jiffies(P9221_NOTIFIER_DELAY_MS)))
		pm_relax(charger->dev);

out:
	return NOTIFY_OK;
}

static int p9221_clear_interrupts(struct p9221_charger_data *charger, u16 mask)
{
	int ret;

	mutex_lock(&charger->cmd_lock);

	ret = p9221_reg_write_16(charger, P9221R5_INT_CLEAR_REG, mask);
	if (ret) {
		dev_err(&charger->client->dev,
			"Failed to clear INT reg: %d\n", ret);
		goto out;
	}

	ret = charger->chip_set_cmd(charger, P9221_COM_CLEAR_INT_MASK);
	if (ret) {
		dev_err(&charger->client->dev,
			"Failed to reset INT: %d\n", ret);
	}
out:
	mutex_unlock(&charger->cmd_lock);
	return ret;
}

/*
 * Enable interrupts on the P9221, note we don't really need to disable
 * interrupts since when the device goes out of field, the P9221 is reset.
 */
static int p9221_enable_interrupts(struct p9221_charger_data *charger)
{
	u16 mask;
	int ret;

	dev_dbg(&charger->client->dev, "Enable interrupts\n");

	if (charger->ben_state) {
		/* enable necessary INT for RTx mode */
		mask = charger->ints.stat_rtx_mask;
	} else {
		mask = charger->ints.stat_limit_mask | charger->ints.stat_cc_mask |
		       charger->ints.vrecton_bit | charger->ints.prop_mode_mask |
		       charger->ints.extended_mode_bit;

		if (charger->pdata->needs_dcin_reset ==
						P9221_WC_DC_RESET_VOUTCHANGED)
			mask |= charger->ints.vout_changed_bit;
		if (charger->pdata->needs_dcin_reset ==
						P9221_WC_DC_RESET_MODECHANGED)
			mask |= charger->ints.mode_changed_bit;
	}
	ret = p9221_clear_interrupts(charger, mask);
	if (ret)
		dev_err(&charger->client->dev,
			"Could not clear interrupts: %d\n", ret);

	ret = p9221_reg_write_16(charger, P9221_INT_ENABLE_REG, mask);
	if (ret)
		dev_err(&charger->client->dev,
			"Could not enable interrupts: %d\n", ret);

	return ret;
}

int p9xxx_sw_ramp_icl(struct p9221_charger_data *charger, const int icl_target)
{
	int step, icl_now;

	if (!charger->pdata->has_sw_ramp)
		return 0;

	icl_now = gvotable_get_current_int_vote(charger->dc_icl_votable);

	dev_dbg(&charger->client->dev, "%s: Set ICL %d->%d ==========\n", __func__, icl_now, icl_target);

	step = (icl_target > icl_now) ? P9XXX_SW_RAMP_ICL_STEP_UA : -P9XXX_SW_RAMP_ICL_STEP_UA;

	while (icl_now != icl_target && charger->online) {
		dev_dbg(&charger->client->dev, "%s: step=%d, get_current_vote=%d\n",
			 __func__,step, gvotable_get_current_int_vote(charger->dc_icl_votable));

		if (abs(icl_target - icl_now) <= P9XXX_SW_RAMP_ICL_STEP_UA)
			icl_now = icl_target;
		else
			icl_now += step;

		dev_dbg(&charger->client->dev, "%s: Voting ICL %duA (t=%d)\n", __func__, icl_now, icl_target);

		gvotable_cast_int_vote(charger->dc_icl_votable, P9221_RAMP_VOTER, icl_now, true);
		usleep_range(100 * USEC_PER_MSEC, 120 * USEC_PER_MSEC);
	}

	if (!charger->online)
		return -ENODEV;

	dev_dbg(&charger->client->dev, "%s: P9221_RAMP_VOTER=%d, get_current_int_vote=%d ==========\n",
                 __func__,
		 gvotable_get_int_vote(charger->dc_icl_votable, P9221_RAMP_VOTER),
		 gvotable_get_current_int_vote(charger->dc_icl_votable));

	return 0;
}

static int p9221_set_dc_icl(struct p9221_charger_data *charger)
{
	int icl, ret;

	if (!charger->dc_icl_votable) {
		charger->dc_icl_votable =
			gvotable_election_get_handle("DC_ICL");
		if (!charger->dc_icl_votable) {
			dev_err(&charger->client->dev,
				"Could not get votable: DC_ICL\n");
			return -ENODEV;
		}
	}

	if (!p9221_is_epp(charger) && charger->last_capacity == 100 && charger->ll_bpp_cep < 0) {
		dev_info(&charger->client->dev, "vote ICL as %d for BPP mode(capacity=%d)\n",
			 P9221_LL_BPP_CHG_TERM_UA, charger->last_capacity);
		gvotable_cast_int_vote(charger->dc_icl_votable, LL_BPP_CEP_VOTER,
				       P9221_LL_BPP_CHG_TERM_UA, true);
	}

	/* Default to BPP ICL */
	icl = P9221_DC_ICL_BPP_UA;

	if (charger->chg_on_rtx)
		icl = P9221_DC_ICL_RTX_UA;

	if (charger->icl_ramp)
		icl = charger->icl_ramp_ua;

	/* forced limit */
	if (charger->dc_icl_bpp)
		icl = charger->dc_icl_bpp;

	if (p9221_is_epp(charger))
		icl = charger->dc_icl_epp_neg;

	if (p9221_is_epp(charger) && charger->dc_icl_epp)
		icl = charger->dc_icl_epp;

 	if (charger->icl_ramp && charger->icl_ramp_alt_ua)
		icl = charger->icl_ramp_alt_ua;

	dev_info(&charger->client->dev, "Voting ICL %duA ramp=%d, alt_ramp=%d\n",
		icl, charger->icl_ramp, charger->icl_ramp_alt_ua);

	if (charger->pdata->has_sw_ramp && !charger->icl_ramp) {
		dev_dbg(&charger->client->dev, "%s: voter=%s\n", __func__, P9221_WLC_VOTER);
		ret = p9xxx_sw_ramp_icl(charger, icl);
		if (ret < 0)
			gvotable_cast_int_vote(charger->dc_icl_votable,
					       P9221_RAMP_VOTER, 0, false);
	}

	if (charger->icl_ramp)
		gvotable_cast_int_vote(charger->dc_icl_votable,
				       DCIN_AICL_VOTER, icl, true);

	ret = gvotable_cast_int_vote(charger->dc_icl_votable,
				     P9221_WLC_VOTER, icl, true);
	if (ret)
		dev_err(&charger->client->dev,
			"Could not vote DC_ICL %d\n", ret);

	if (charger->pdata->has_sw_ramp && !charger->icl_ramp)
		gvotable_cast_int_vote(charger->dc_icl_votable, P9221_RAMP_VOTER, 0, false);

	/* Increase the IOUT limit */
	charger->chip_set_rx_ilim(charger, P9221_UA_TO_MA(P9221R5_ILIM_MAX_UA));
	if (ret)
		dev_err(&charger->client->dev,
			"Could not set rx_iout limit reg: %d\n", ret);

	return ret;
}

static enum alarmtimer_restart p9221_auth_dc_icl_alarm_cb(struct alarm *alarm,
							  ktime_t now)
{
	struct p9221_charger_data *charger =
			container_of(alarm, struct p9221_charger_data,
				     auth_dc_icl_alarm);

	/* Alarm is in atomic context, schedule work to complete the task */
	dev_info(&charger->client->dev, "Auth timeout, reset DC_ICL\n");
	schedule_delayed_work(&charger->auth_dc_icl_work, msecs_to_jiffies(100));
	return ALARMTIMER_NORESTART;
}

/*
 * only for Qi 1.3 EPP Tx,
 * < 0 error, 0 no support, != support
 */
static int p9221_check_qi1_3_auth(struct p9221_charger_data *chgr)
{
	u8 temp = 0;
	int ret;

	ret = p9221_reg_read_8(chgr, P9221R5_EPP_TX_CAPABILITY_FLAGS_REG, &temp);
	pr_debug("%s: caps=%x (%d)\n", __func__, temp, ret);
	if (ret < 0)
		return -EIO;

	return !!(temp & P9221R5_EPP_TX_CAPABILITY_FLAGS_AR);
}

static void p9221_auth_dc_icl_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, auth_dc_icl_work.work);
	const ktime_t elap = get_boot_sec() - charger->online_at;
	int auth_check = 0;

	mutex_lock(&charger->auth_lock);

	if (elap >= WLCDC_DEBOUNCE_TIME_S)
		p9221_set_auth_dc_icl(charger, false);

	/* done already */
	if (!charger->auth_delay || !p9221_is_online(charger))
		goto exit_done;

	/*
	 * check_id for Qi 1.2.4 EPP Tx and check Qi1.3 EPP Tx until the id is
	 * available (i.e. return different from -EGAIN)
	 */
	if (p9221_is_epp(charger)) {
		auth_check = p9221_ll_check_id(charger);
		if (auth_check == -EAGAIN)
			auth_check = p9221_check_qi1_3_auth(charger);
	}

	pr_debug("%s: online_at=%lld elap=%lld timeout=%d auth_check=%d\n",
		__func__, charger->online_at, elap, WLCDC_AUTH_CHECK_S,
		auth_check);

	/* b/202213483 retry for WLCDC_AUTH_CHECK_S */
	if (auth_check <= 0 && elap < WLCDC_AUTH_CHECK_S)
		auth_check = -EAGAIN;

	/* p9221_auth_dc_icl_alarm_cb() will reschedule at timeout */
	if (auth_check == 0) {
		p9221_set_auth_dc_icl(charger, false);

		/* TODO: use a different wakesource? */
		pm_relax(charger->dev);
	} else if (auth_check < 0) {
		schedule_delayed_work(&charger->auth_dc_icl_work,
				      msecs_to_jiffies(WLCDC_AUTH_CHECK_INTERVAL_MS));
	} else {
		dev_info(&charger->client->dev,
			 "Auth limit online_at=%lld, will timeout in %llds\n",
			 charger->online_at, WLCDC_DEBOUNCE_TIME_S - elap);
	}

exit_done:
	mutex_unlock(&charger->auth_lock);
}

static enum alarmtimer_restart p9221_icl_ramp_alarm_cb(struct alarm *alarm,
						       ktime_t now)
{
	struct p9221_charger_data *charger =
			container_of(alarm, struct p9221_charger_data,
				     icl_ramp_alarm);

	/* should not schedule icl_ramp_work if charge on rtx phone */
	if (charger->chg_on_rtx)
		return ALARMTIMER_NORESTART;

	dev_info(&charger->client->dev, "ICL ramp alarm, ramp=%d\n",
		 charger->icl_ramp);

	/* Alarm is in atomic context, schedule work to complete the task */
	pm_stay_awake(charger->dev);
	schedule_delayed_work(&charger->icl_ramp_work, msecs_to_jiffies(100));

	return ALARMTIMER_NORESTART;
}

static void p9221_icl_ramp_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, icl_ramp_work.work);

	pm_runtime_get_sync(charger->dev);
	if (!charger->resume_complete) {
		pm_runtime_put_sync(charger->dev);
		schedule_delayed_work(&charger->icl_ramp_work,
				      msecs_to_jiffies(100));
		dev_dbg(&charger->client->dev, "Ramp reschedule\n");
		return;
	}
	pm_runtime_put_sync(charger->dev);

	dev_info(&charger->client->dev, "ICL ramp work, ramp=%d\n",
		 charger->icl_ramp);

	charger->icl_ramp = true;
	p9221_set_dc_icl(charger);

	pm_relax(charger->dev);
}

static void p9221_icl_ramp_reset(struct p9221_charger_data *charger)
{
	dev_info(&charger->client->dev, "ICL ramp reset, ramp=%d\n",
		 charger->icl_ramp);

	charger->icl_ramp = false;

	if (alarm_try_to_cancel(&charger->icl_ramp_alarm) < 0)
		dev_warn(&charger->client->dev, "Couldn't cancel icl_ramp_alarm\n");
	cancel_delayed_work(&charger->icl_ramp_work);
}

static void p9221_icl_ramp_start(struct p9221_charger_data *charger)
{
	const bool no_ramp = charger->pdata->icl_ramp_delay_ms == -1 ||
			     !charger->icl_ramp_ua;

	/* Only ramp on BPP at this time */
	if (p9221_is_epp(charger) || no_ramp)
		return;

	p9221_icl_ramp_reset(charger);

	dev_info(&charger->client->dev, "ICL ramp set alarm %dms, %dua, ramp=%d\n",
		 charger->pdata->icl_ramp_delay_ms, charger->icl_ramp_ua,
		 charger->icl_ramp);

	alarm_start_relative(&charger->icl_ramp_alarm,
			     ms_to_ktime(charger->pdata->icl_ramp_delay_ms));
}

static void p9xxx_check_ll_bpp_cep(struct p9221_charger_data *charger)
{
	int ret, ll_icl_ua;
	u32 vout_mv = 0;
	u8 val8 = 0;
	bool is_ll_bpp = true;

	ll_icl_ua = gvotable_get_int_vote(charger->dc_icl_votable, LL_BPP_CEP_VOTER);

	if (ll_icl_ua <= 0 || charger->ll_bpp_cep == 1)
		return;

	if (p9221_is_epp(charger))
		is_ll_bpp = false;

	ret = charger->chip_get_vout_max(charger, &vout_mv);
	if (ret < 0 || vout_mv != P9XXX_VOUT_5480MV)
		is_ll_bpp = false;
	ret = p9221_reg_read_8(charger, P9412_CMFET_L_REG, &val8);
	if (ret < 0 || val8 != 0)
		is_ll_bpp = false;

	if (is_ll_bpp) {
		charger->ll_bpp_cep = 1;
		dev_info(&charger->client->dev, "ll_bpp_cep = %d\n", charger->ll_bpp_cep);
	} else {
		charger->ll_bpp_cep = 0;
		dev_info(&charger->client->dev,
			 "remove LL_BPP_CEP_VOTER(capacity=%d)\n", charger->last_capacity);
		gvotable_cast_int_vote(charger->dc_icl_votable, LL_BPP_CEP_VOTER, 0, false);
	}
}

static void p9221_set_online(struct p9221_charger_data *charger)
{
	int ret;
	u8 cid = 5;

	dev_info(&charger->client->dev, "Set online\n");

	mutex_lock(&charger->stats_lock);
	charger->online = true;
	charger->tx_busy = false;
	charger->tx_done = true;
	charger->rx_done = false;
	charger->cc_data_lock.cc_use = false;
	charger->cc_data_lock.cc_rcv_at = 0;
	charger->last_capacity = -1;
	charger->online_at = get_boot_sec();

	/* reset data for the new charging entry */

	p9221_charge_stats_init(&charger->chg_data);
	mutex_unlock(&charger->stats_lock);

	ret = p9221_reg_read_8(charger, P9221_CUSTOMER_ID_REG, &cid);
	if (ret)
		dev_err(&charger->client->dev, "Could not get ID: %d\n", ret);
	else
		charger->cust_id = cid;

	dev_info(&charger->client->dev, "P9221 cid: %02x\n", charger->cust_id);

	ret = p9221_enable_interrupts(charger);
	if (ret)
		dev_err(&charger->client->dev,
			"Could not enable interrupts: %d\n", ret);

	/* NOTE: depends on _is_epp() which is not valid until DC_IN */
	p9221_write_fod(charger);

	cancel_delayed_work(&charger->dcin_pon_work);

	charger->alignment_capable = ALIGN_MFG_CHECKING;
	charger->align = WLC_ALIGN_CENTERED;
	charger->alignment = -1;
	logbuffer_log(charger->log, "align: state: %s",
		      align_status_str[charger->align]);
	schedule_work(&charger->uevent_work);

	schedule_delayed_work(&charger->charge_stats_work,
			      msecs_to_jiffies(P9221_CHARGE_STATS_TIMEOUT_MS));

	/* Auth: set alternate ICL for comms and start auth timers */
	if (charger->pdata->has_wlc_dc) {
		const ktime_t timeout = ms_to_ktime(WLCDC_DEBOUNCE_TIME_S * 1000);

		mutex_lock(&charger->auth_lock);

		ret = p9221_set_auth_dc_icl(charger, true);
		if (ret < 0)
			dev_err(&charger->client->dev, "cannot set Auth ICL: %d\n", ret);

		pm_stay_awake(charger->dev);
		alarm_start_relative(&charger->auth_dc_icl_alarm, timeout);
		schedule_delayed_work(&charger->auth_dc_icl_work,
				      msecs_to_jiffies(WLCDC_AUTH_CHECK_INIT_DELAY_MS));

		mutex_unlock(&charger->auth_lock);
	}

}

static int p9221_set_bpp_vout(struct p9221_charger_data *charger)
{
	u32 vout_mv;
	int ret, loops;
	const u32 vout_5000mv = 5000;

	for (loops = 0; loops < 10; loops++) {
		ret = charger->chip_set_vout_max(charger, vout_5000mv);
		if (ret < 0) {
			dev_err(&charger->client->dev,
				"cannot set VOUT (%d)\n", ret);
			return ret;
		}

		ret = charger->chip_get_vout_max(charger, &vout_mv);
		if (ret < 0) {
			dev_err(&charger->client->dev,
				"cannot read VOUT (%d)\n", ret);
			return ret;
		}

		if (vout_mv == vout_5000mv)
			return 0;

		msleep(10);
	}

	return -ETIMEDOUT;
}

/* return <0 on error, 0 on done, 1 on keep trying */
static int p9221_notifier_check_neg_power(struct p9221_charger_data *charger)
{
	u8 np8;
	int ret;
	u16 status_reg;

	ret = p9221_reg_read_8(charger, P9221R5_EPP_CUR_NEGOTIATED_POWER_REG,
			       &np8);
	if (ret < 0) {
		dev_err(&charger->client->dev,
			"cannot read EPP_NEG_POWER (%d)\n", ret);
		return -EIO;
	}

	if (np8 >= P9221_NEG_POWER_10W) {
		u16 mfg;

		ret = p9xxx_chip_get_tx_mfg_code(charger, &mfg);
		if (ret < 0) {
			dev_err(&charger->client->dev,
				"cannot read MFG_CODE (%d)\n", ret);
			return -EIO;
		}


		/* EPP unless dealing with P9221_PTMC_EPP_TX_1912 */
		charger->force_bpp = (mfg == P9221_PTMC_EPP_TX_1912);
		dev_info(&charger->client->dev, "np=%x mfg=%x fb=%d\n",
			 np8, mfg, charger->force_bpp);
		goto done;
	}

	ret = p9221_reg_read_16(charger, P9221_STATUS_REG, &status_reg);
	if (ret) {
		dev_err(&charger->client->dev,
			"failed to read P9221_STATUS_REG reg: %d\n",
			ret);
		return ret;
	}

	/* VOUT for standard BPP comes much earlier that VOUT for EPP */
	if (!(status_reg & charger->ints.vout_changed_bit))
		return 1;

	/* normal BPP TX or EPP at less than 10W */
	charger->force_bpp = true;
	dev_info(&charger->client->dev,
			"np=%x normal BPP or EPP less than 10W (%d)\n",
			np8, ret);

done:
	if (charger->force_bpp) {
		ret = p9221_set_bpp_vout(charger);
		if (ret)
			dev_err(&charger->client->dev,
				"cannot change VOUT (%d)\n", ret);
	}

	return 0;
}

/* 2 P9221_NOTIFIER_DELAY_MS from VRECTON */
static void p9221_notifier_check_dc(struct p9221_charger_data *charger)
{
	int ret, dc_in;

	if ((charger->chip_id == P9221_CHIP_ID) && charger->check_np) {

		ret = p9221_notifier_check_neg_power(charger);
		if (ret > 0) {
			ret = schedule_delayed_work(&charger->notifier_work,
				msecs_to_jiffies(P9221_CHECK_NP_DELAY_MS));
			if (ret == 0)
				return;

			dev_err(&charger->client->dev,
				"cannot reschedule check_np (%d)\n", ret);
		}

		/* done */
		charger->check_np = false;
	}

	dc_in = p9221_has_dc_in(charger);
	if (dc_in < 0) {
          	dev_info(&charger->client->dev, "reschedule it(%d)\n", dc_in);
		schedule_delayed_work(&charger->notifier_work,
				    msecs_to_jiffies(P9221_DCIN_RETRY_DELAY_MS));
		return;
	}

	dev_info(&charger->client->dev, "dc status is %d\n", dc_in);
  	charger->check_dc = false;
	/*
	 * We now have confirmation from DC_IN, kill the timer, charger->online
	 * will be set by this function.
	 */
	cancel_delayed_work(&charger->dcin_work);
	del_timer(&charger->vrect_timer);

	if (charger->log) {
		u32 vout_uv;
		u32 vout_mv;

		ret = charger->chip_get_vout(charger, &vout_mv);
		if (!ret)
			vout_uv = P9221_MV_TO_UV(vout_mv);

		logbuffer_log(charger->log,
			      "check_dc: online=%d present=%d VOUT=%uuV (%d)",
			      charger->online, dc_in,
			      (ret == 0) ? vout_uv : 0, ret);
	}

	/*
	 * Always write FOD, check dc_icl, send CSP
	 */
	if (dc_in) {
		if (p9221_is_epp(charger))
			charger->chip_check_neg_power(charger);

		if (charger->pdata->has_sw_ramp && !charger->sw_ramp_done) {
			gvotable_cast_int_vote(charger->dc_icl_votable,
					       P9221_RAMP_VOTER,
					       P9XXX_SW_RAMP_ICL_START_UA, true);
			charger->sw_ramp_done = true;
		}
		p9221_set_dc_icl(charger);
		p9221_write_fod(charger);
		if (!charger->dc_icl_bpp)
			p9221_icl_ramp_start(charger);

		/* Check if Tx in LL BPP mode */
		p9xxx_check_ll_bpp_cep(charger);

		ret = p9221_reg_read_16(charger, P9221_OTP_FW_MINOR_REV_REG,
					&charger->fw_rev);
		if (ret)
			dev_err(&charger->client->dev,
				"Could not get FW_REV: %d\n", ret);
	}

	/* We may have already gone online during check_det */
	if (charger->online == dc_in)
		goto out;

	if (dc_in)
		p9221_set_online(charger);
	else
		p9221_set_offline(charger);

out:
	dev_info(&charger->client->dev, "trigger wc changed on:%d in:%d\n",
		 charger->online, dc_in);
	power_supply_changed(charger->wc_psy);
}

/* P9221_NOTIFIER_DELAY_MS from VRECTON */
static bool p9221_notifier_check_det(struct p9221_charger_data *charger)
{
	bool relax = true;

	del_timer(&charger->vrect_timer);

	if (charger->online && !charger->ben_state)
		goto done;

	dev_info(&charger->client->dev, "detected wlc, trigger wc changed\n");

	/* b/130637382 workaround for 2622,2225,2574,1912 */
	charger->check_np = true;
	/* will send out a FOD but is_epp() is still invalid */
	p9221_set_online(charger);
	power_supply_changed(charger->wc_psy);

	/* Check dc-in every seconds as long as we are in field. */
	dev_info(&charger->client->dev, "start dc-in timer\n");
	cancel_delayed_work_sync(&charger->dcin_work);
	schedule_delayed_work(&charger->dcin_work,
			      msecs_to_jiffies(P9221_DCIN_TIMEOUT_MS));
	relax = false;

done:
	charger->check_det = false;

	return relax;
}

static void p9xxx_write_q_factor(struct p9221_charger_data *charger)
{
	int ret, q_factor;

	if (charger->pdata->q_value == -1 && charger->de_q_value == 0)
		return;

	q_factor = (charger->de_q_value > 0) ?
		   charger->de_q_value : charger->pdata->q_value;

	ret = p9xxx_chip_set_q_factor_reg(charger, q_factor);
	if (ret < 0)
		dev_err(&charger->client->dev,
			"cannot write Q=%d (%d)\n",
			q_factor, ret);
}

static void p9xxx_update_q_factor(struct p9221_charger_data *charger)
{
	int ret, i;

	for (i = 0; i < 5; i += 1) {
		ret = p9xxx_chip_get_tx_mfg_code(charger, &charger->mfg);
		if (ret == 0 && charger->mfg != 0)
			break;
		usleep_range(100 * USEC_PER_MSEC, 120 * USEC_PER_MSEC);
	}

	if (charger->mfg == P9221_PTMC_EPP_TX_4191) {
		ret = p9xxx_chip_set_q_factor_reg(charger, charger->pdata->tx_4191q);
		if (ret == 0)
			dev_info(&charger->client->dev,
				 "update Q factor=%d(mfg=%x)\n",
				 charger->pdata->tx_4191q, charger->mfg);
	};
}

static void p9221_notifier_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, notifier_work.work);
	bool relax = true;
	int ret;

	dev_info(&charger->client->dev, "Notifier work: on:%d ben:%d dc:%d np:%d det:%d\n",
		 charger->online,
		 charger->ben_state,
		 charger->check_dc, charger->check_np,
		 charger->check_det);

	charger->send_eop = gvotable_get_int_vote(charger->dc_icl_votable,
						  THERMAL_DAEMON_VOTER) == 0;
	if (charger->send_eop && !charger->online) {
		dev_info(&charger->client->dev, "WLC should be disabled!\n");
		p9221_wlc_disable(charger, 1, P9221_EOP_UNKNOWN);
		goto done_relax;
	}

	/* Calibrate light load */
	if (charger->pdata->light_load)
		p9xxx_chip_set_light_load_reg(charger, P9222_LIGHT_LOAD_VALUE);

	p9xxx_write_q_factor(charger);
	if (charger->pdata->tx_4191q > 0)
		p9xxx_update_q_factor(charger);

	if (charger->pdata->epp_rp_value != -1) {

		ret = charger->chip_renegotiate_pwr(charger);
		if (ret < 0)
			dev_err(&charger->client->dev,
				"cannot renegotiate power=%d (%d)\n",
				 charger->pdata->epp_rp_value, ret);
	}

	if (charger->log) {
		u32 vrect_mv;

		ret = charger->chip_get_vrect(charger, &vrect_mv);
		logbuffer_log(charger->log,
			      "notifier: on:%d ben:%d dc:%d det:%d VRECT=%uuV (%d)",
			      charger->online,
			      charger->ben_state,
			      charger->check_dc, charger->check_det,
			      (ret == 0) ? P9221_MV_TO_UV(vrect_mv) : 0, ret);
		}

	if (charger->check_det)
		relax = p9221_notifier_check_det(charger);

	if (charger->check_dc)
		p9221_notifier_check_dc(charger);

done_relax:
	if (relax)
		pm_relax(charger->dev);
}

static size_t p9221_add_buffer(char *buf, u32 val, size_t count, int ret,
			       const char *name, char *fmt)
{
	int added = 0;

	added += scnprintf(buf + count, PAGE_SIZE - count, "%s", name);
	count += added;
	if (ret)
		added += scnprintf(buf + count, PAGE_SIZE - count,
				   "err %d\n", ret);
	else
		added += scnprintf(buf + count, PAGE_SIZE - count, fmt, val);

	return added;
}

static ssize_t p9221_add_reg_buffer(struct p9221_charger_data *charger,
				    char *buf, size_t count, u16 reg, int width,
				    bool cooked, const char *name, char *fmt)
{
	u32 val;
	int ret;

	if (width == 16) {
		u16 val16 = 0;

		ret = p9221_reg_read_16(charger, reg, &val16);
		val = val16;
	} else {
		u8 val8 = 0;

		ret = p9221_reg_read_8(charger, reg, &val8);
		val = val8;
	}

	return p9221_add_buffer(buf, val, count, ret, name, fmt);
}

static ssize_t p9221_show_version(struct device *dev,
				  struct device_attribute *attr,
				  char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int count = 0;
	int i;
	u8 val8 = 0;

	if (!p9221_is_online(charger))
		return -ENODEV;

	count += p9221_add_reg_buffer(charger, buf, count, P9221_CHIP_ID_REG,
				      16, 0, "chip id    : ", "%04x\n");
	count += p9221_add_reg_buffer(charger, buf, count,
				      P9221_CHIP_REVISION_REG, 8, 0,
				      "chip rev   : ", "%02x\n");
	count += p9221_add_reg_buffer(charger, buf, count,
				      P9221_CUSTOMER_ID_REG, 8, 0,
				      "cust id    : ", "%02x\n");
	count += p9221_add_reg_buffer(charger, buf, count,
				      P9221_OTP_FW_MAJOR_REV_REG, 16, 0,
				      "otp fw maj : ", "%04x\n");
	count += p9221_add_reg_buffer(charger, buf, count,
				      P9221_OTP_FW_MINOR_REV_REG, 16, 0,
				      "otp fw min : ", "%04x\n");

	count += scnprintf(buf + count, PAGE_SIZE - count, "otp fw date: ");
	for (i = 0; i < P9221_OTP_FW_DATE_SIZE; i++) {
		p9221_reg_read_8(charger,
				       P9221_OTP_FW_DATE_REG + i, &val8);
		if (val8)
			count += scnprintf(buf + count, PAGE_SIZE - count,
					   "%c", val8);
	}

	count += scnprintf(buf + count, PAGE_SIZE - count, "\notp fw time: ");
	for (i = 0; i < P9221_OTP_FW_TIME_SIZE; i++) {
		p9221_reg_read_8(charger,
				       P9221_OTP_FW_TIME_REG + i, &val8);
		if (val8)
			count += scnprintf(buf + count, PAGE_SIZE - count,
					   "%c", val8);
	}

	count += p9221_add_reg_buffer(charger, buf, count,
				      P9221_SRAM_FW_MAJOR_REV_REG, 16, 0,
				      "\nram fw maj : ", "%04x\n");
	count += p9221_add_reg_buffer(charger, buf, count,
				      P9221_SRAM_FW_MINOR_REV_REG, 16, 0,
				      "ram fw min : ", "%04x\n");

	count += scnprintf(buf + count, PAGE_SIZE - count, "ram fw date: ");
	for (i = 0; i < P9221_SRAM_FW_DATE_SIZE; i++) {
		p9221_reg_read_8(charger,
				       P9221_SRAM_FW_DATE_REG + i, &val8);
		if (val8)
			count += scnprintf(buf + count, PAGE_SIZE - count,
					   "%c", val8);
	}

	count += scnprintf(buf + count, PAGE_SIZE - count, "\nram fw time: ");
	for (i = 0; i < P9221_SRAM_FW_TIME_SIZE; i++) {
		p9221_reg_read_8(charger,
				       P9221_SRAM_FW_TIME_REG + i, &val8);
		if (val8)
			count += scnprintf(buf + count, PAGE_SIZE - count,
					   "%c", val8);
	}

	count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
	return count;
}

static DEVICE_ATTR(version, 0444, p9221_show_version, NULL);

static ssize_t p9221_show_status(struct device *dev,
				 struct device_attribute *attr,
				 char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int count = 0;
	int ret;
	u8 tmp[P9221R5_NUM_FOD];
	uint32_t tx_id = 0;
	u32 val32;
	u16 val16;
	u8 val8;

	if (!p9221_is_online(charger))
		return -ENODEV;

	ret = p9221_reg_read_16(charger, P9221_STATUS_REG, &val16);
	count += p9221_add_buffer(buf, val16, count, ret,
				  "status      : ", "%04x\n");

	ret = p9221_reg_read_16(charger, P9221_INT_REG, &val16);
	count += p9221_add_buffer(buf, val16, count, ret,
				  "int         : ", "%04x\n");

	ret = p9221_reg_read_16(charger, P9221_INT_ENABLE_REG, &val16);
	count += p9221_add_buffer(buf, val16, count, ret,
				  "int_enable  : ", "%04x\n");

	ret = charger->chip_get_sys_mode(charger, &val8);
	count += p9221_add_buffer(buf, val8, count, ret,
				  "mode        : ", "%02x\n");

	ret = charger->chip_get_vout(charger, &val32);
	count += p9221_add_buffer(buf, P9221_MV_TO_UV(val32), count, ret,
				  "vout        : ", "%u uV\n");

	ret = charger->chip_get_vrect(charger, &val32);
	count += p9221_add_buffer(buf, P9221_MV_TO_UV(val32), count, ret,
				  "vrect       : ", "%u uV\n");

	ret = charger->chip_get_iout(charger, &val32);
	count += p9221_add_buffer(buf, P9221_MA_TO_UA(val32), count, ret,
				  "iout        : ", "%u uA\n");

	if (charger->ben_state == 1)
		ret = charger->chip_get_tx_ilim(charger, &val32);
	else
		ret = charger->chip_get_rx_ilim(charger, &val32);
	count += p9221_add_buffer(buf, P9221_MA_TO_UA(val32), count, ret,
				  "ilim        : ", "%u uA\n");

	ret = charger->chip_get_op_freq(charger, &val32);
	count += p9221_add_buffer(buf, P9221_KHZ_TO_HZ(val32), count, ret,
				  "freq        : ", "%u hz\n");
	count += scnprintf(buf + count, PAGE_SIZE - count,
			   "tx_busy     : %d\n", charger->tx_busy);
	count += scnprintf(buf + count, PAGE_SIZE - count,
			   "tx_done     : %d\n", charger->tx_done);
	count += scnprintf(buf + count, PAGE_SIZE - count,
			   "rx_done     : %d\n", charger->rx_done);
	count += scnprintf(buf + count, PAGE_SIZE - count,
			   "tx_len      : %d\n", charger->tx_len);
	count += scnprintf(buf + count, PAGE_SIZE - count,
			   "rx_len      : %d\n", charger->rx_len);
	p9xxx_chip_get_tx_id(charger, &tx_id);
	count += scnprintf(buf + count, PAGE_SIZE - count,
			   "tx_id       : %08x (%s)\n", tx_id,
			   p9221_get_tx_id_str(charger));

	ret = charger->chip_get_align_x(charger, &val8);
	count += p9221_add_buffer(buf, val8, count, ret,
				  "align_x     : ", "%u\n");

	ret = charger->chip_get_align_y(charger, &val8);
	count += p9221_add_buffer(buf, val8, count, ret,
				  "align_y     : ", "%u\n");

	/* WLC_DC state */
	if (charger->prop_mode_en) {
		ret = charger->reg_read_8(charger, P9412_PROP_CURR_PWR_REG,
					  &val8);
		count += p9221_add_buffer(buf, val8, count, ret,
					  "curr_pwr_reg: ", "%02x\n");
	}

	/* FOD Register */
	ret = p9xxx_chip_get_fod_reg(charger, tmp, P9221R5_NUM_FOD);
	count += scnprintf(buf + count, PAGE_SIZE - count, "fod         : ");
	if (ret)
		count += scnprintf(buf + count, PAGE_SIZE - count,
				   "err %d\n", ret);
	else {
		count += p9221_hex_str(tmp, P9221R5_NUM_FOD, buf + count, count,
				       false);
		count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
	}

	/* Device tree FOD entries */
	count += scnprintf(buf + count, PAGE_SIZE - count,
			   "dt fod      : (n=%d) ", charger->pdata->fod_num);
	count += p9221_hex_str(charger->pdata->fod, charger->pdata->fod_num,
			       buf + count, PAGE_SIZE - count, false);

	count += scnprintf(buf + count, PAGE_SIZE - count,
			   "\ndt fod-epp  : (n=%d) ",
			   charger->pdata->fod_epp_num);
	count += p9221_hex_str(charger->pdata->fod_epp,
			       charger->pdata->fod_epp_num,
			       buf + count, PAGE_SIZE - count, false);

	count += scnprintf(buf + count, PAGE_SIZE - count,
			   "\ndt fod-hpp  : (n=%d) ",
			   charger->pdata->fod_hpp_num);
	count += p9221_hex_str(charger->pdata->fod_hpp,
			       charger->pdata->fod_hpp_num,
			       buf + count, PAGE_SIZE - count, false);

	count += scnprintf(buf + count, PAGE_SIZE - count,
			   "\npp buf      : (v=%d) ", charger->pp_buf_valid);
	count += p9221_hex_str(charger->pp_buf, sizeof(charger->pp_buf),
			       buf + count, PAGE_SIZE - count, false);

	count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
	return count;
}

static DEVICE_ATTR(status, 0444, p9221_show_status, NULL);

static ssize_t p9221_show_count(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%u\n", charger->count);
}

static ssize_t p9221_store_count(struct device *dev,
				 struct device_attribute *attr,
				 const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret;
	u8 cnt;

	ret = kstrtou8(buf, 0, &cnt);
	if (ret < 0)
		return ret;
	charger->count = cnt;
	return count;
}

static DEVICE_ATTR(count, 0644, p9221_show_count, p9221_store_count);

static ssize_t p9221_show_icl_ramp_delay_ms(struct device *dev,
					    struct device_attribute *attr,
					    char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n",
			 charger->pdata->icl_ramp_delay_ms);
}

static ssize_t p9221_store_icl_ramp_delay_ms(struct device *dev,
					     struct device_attribute *attr,
					     const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret;
	u32 ms;

	ret = kstrtou32(buf, 10, &ms);
	if (ret < 0)
		return ret;
	charger->pdata->icl_ramp_delay_ms = ms;
	return count;
}

static DEVICE_ATTR(icl_ramp_delay_ms, 0644,
		   p9221_show_icl_ramp_delay_ms,
		   p9221_store_icl_ramp_delay_ms);

static ssize_t p9221_show_icl_ramp_ua(struct device *dev,
				      struct device_attribute *attr,
				      char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->icl_ramp_ua);
}

static ssize_t p9221_store_icl_ramp_ua(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret;
	u32 ua;

	ret = kstrtou32(buf, 10, &ua);
	if (ret < 0)
		return ret;
	charger->icl_ramp_ua = ua;
	return count;
}

static DEVICE_ATTR(icl_ramp_ua, 0644,
		   p9221_show_icl_ramp_ua, p9221_store_icl_ramp_ua);

static ssize_t p9221_show_addr(struct device *dev,
			       struct device_attribute *attr,
			       char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%04x\n", charger->addr);
}

static ssize_t p9221_store_addr(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret;
	u16 addr;

	ret = kstrtou16(buf, 16, &addr);
	if (ret < 0)
		return ret;
	charger->addr = addr;
	return count;
}

static DEVICE_ATTR(addr, 0644, p9221_show_addr, p9221_store_addr);

static ssize_t p9221_show_data(struct device *dev,
			       struct device_attribute *attr,
			       char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	u8 reg[256];
	int ret;
	int i;
	ssize_t len = 0;

	if (!charger->count || (charger->addr > (0xFFFF - charger->count)))
		return -EINVAL;

	if (!p9221_is_online(charger))
		return -ENODEV;

	ret = p9221_reg_read_n(charger, charger->addr, reg, charger->count);
	if (ret)
		return ret;

	for (i = 0; i < charger->count; i++) {
		len += scnprintf(buf + len, PAGE_SIZE - len, "%02x: %02x\n",
				 charger->addr + i, reg[i]);
	}
	return len;
}

static ssize_t p9221_store_data(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	u8 reg[256];
	int i = 0;
	int ret = 0;
	char *data;
	char *tmp_buf;

	if (!charger->count || (charger->addr > (0xFFFF - charger->count)))
		return -EINVAL;

	if (!p9221_is_online(charger))
		return -ENODEV;

	tmp_buf = kstrdup(buf, GFP_KERNEL);
	data = tmp_buf;
	if (!data)
		return -ENOMEM;

	while (data && i < charger->count) {
		char *d = strsep(&data, " ");

		if (*d) {
			ret = kstrtou8(d, 16, &reg[i]);
			if (ret)
				break;
			i++;
		}
	}
	if ((i != charger->count) || ret) {
		ret = -EINVAL;
		goto out;
	}

	ret = p9221_reg_write_n(charger, charger->addr, reg, charger->count);
	if (ret)
		goto out;
	ret = count;

out:
	kfree(tmp_buf);
	return ret;
}

static DEVICE_ATTR(data, 0644, p9221_show_data, p9221_store_data);

static ssize_t p9221_store_ccreset(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret;

	ret = p9221_send_ccreset(charger);
	if (ret)
		return ret;
	return count;
}

static DEVICE_ATTR(ccreset, 0200, NULL, p9221_store_ccreset);

static ssize_t p9221_show_rxdone(struct device *dev,
				 struct device_attribute *attr,
				 char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	buf[0] = charger->rx_done ? '1' : '0';
	buf[1] = 0;
	return 1;
}

static DEVICE_ATTR(rxdone, 0444, p9221_show_rxdone, NULL);

static ssize_t p9221_show_rxlen(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%hu\n", charger->rx_len);
}

static DEVICE_ATTR(rxlen, 0444, p9221_show_rxlen, NULL);

static ssize_t p9221_show_txdone(struct device *dev,
				 struct device_attribute *attr,
				 char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	buf[0] = charger->tx_done ? '1' : '0';
	buf[1] = 0;
	return 1;
}

static DEVICE_ATTR(txdone, 0444, p9221_show_txdone, NULL);

static ssize_t p9221_show_txbusy(struct device *dev,
				 struct device_attribute *attr,
				 char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	buf[0] = charger->tx_busy ? '1' : '0';
	buf[1] = 0;
	return 1;
}

static DEVICE_ATTR(txbusy, 0444, p9221_show_txbusy, NULL);

static ssize_t p9221_store_txlen(struct device *dev,
				 struct device_attribute *attr,
				 const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret;
	u16 len;

	ret = kstrtou16(buf, 16, &len);
	if (ret < 0)
		return ret;

	if (!charger->online)
		return -ENODEV;

	/* Don't send bidi data in cases of BPP and NOT dream-defend */
	if (!p9221_is_epp(charger) && !charger->trigger_power_mitigation)
		return -EINVAL;

	charger->tx_len = len;

	ret = set_renego_state(charger, P9XXX_SEND_DATA);
	if (ret != 0)
		return -EBUSY;
	charger->tx_done = false;
	ret = p9221_send_data(charger);
	if (ret) {
		charger->tx_done = true;
		return ret;
	}

	cancel_delayed_work_sync(&charger->tx_work);
	schedule_delayed_work(&charger->tx_work,
			      msecs_to_jiffies(P9221_TX_TIMEOUT_MS));

	return count;
}

static DEVICE_ATTR(txlen, 0200, NULL, p9221_store_txlen);

static ssize_t authtype_store(struct device *dev,
			      struct device_attribute *attr,
			      const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret;
	u16 type;

	ret = kstrtou16(buf, 16, &type);
	if (ret < 0)
		return ret;

	charger->auth_type = type;

	return count;
}

static DEVICE_ATTR_WO(authtype);

static ssize_t p9221_show_force_epp(struct device *dev,
				    struct device_attribute *attr,
				    char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	buf[0] = charger->fake_force_epp ? '1' : '0';
	buf[1] = 0;
	return 1;
}

static ssize_t p9221_force_epp(struct device *dev,
			      struct device_attribute *attr,
			      const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret;
	u16 val;

	ret = kstrtou16(buf, 16, &val);
	if (ret < 0)
		return ret;

	charger->fake_force_epp = (val != 0);

	if (charger->pdata->slct_gpio >= 0)
		gpio_set_value_cansleep(charger->pdata->slct_gpio,
			       charger->fake_force_epp ? 1 : 0);
	return count;
}

static DEVICE_ATTR(force_epp, 0600, p9221_show_force_epp, p9221_force_epp);

static ssize_t dc_icl_epp_show(struct device *dev,
			       struct device_attribute *attr,
			       char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->dc_icl_epp);
}

static ssize_t dc_icl_epp_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret = 0;
	u32 ua;

	ret = kstrtou32(buf, 10, &ua);
	if (ret < 0)
		return ret;

	charger->dc_icl_epp = ua;

	if (charger->dc_icl_votable && p9221_is_epp(charger))
		gvotable_cast_int_vote(charger->dc_icl_votable, P9221_WLC_VOTER,
				       charger->dc_icl_epp, true);

	return count;
}

static DEVICE_ATTR_RW(dc_icl_epp);

static ssize_t p9221_show_dc_icl_bpp(struct device *dev,
				     struct device_attribute *attr,
				     char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->dc_icl_bpp);
}

static ssize_t p9221_set_dc_icl_bpp(struct device *dev,
				    struct device_attribute *attr,
				    const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret = 0;
	u32 ua;

	ret = kstrtou32(buf, 10, &ua);
	if (ret < 0)
		return ret;

	charger->dc_icl_bpp = ua;

	if (charger->dc_icl_votable && !p9221_is_epp(charger))
		gvotable_cast_int_vote(charger->dc_icl_votable, P9221_WLC_VOTER,
				       charger->dc_icl_bpp, true);

	return count;
}

static DEVICE_ATTR(dc_icl_bpp, 0644,
		   p9221_show_dc_icl_bpp, p9221_set_dc_icl_bpp);

static ssize_t p9221_show_alignment(struct device *dev,
				    struct device_attribute *attr,
				    char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	if (charger->alignment == -1)
		p9221_init_align(charger);

	if ((charger->align != WLC_ALIGN_CENTERED) ||
	    (charger->alignment == -1))
		return scnprintf(buf, PAGE_SIZE, "%s\n",
				 align_status_str[charger->align]);
	else
		return scnprintf(buf, PAGE_SIZE, "%d\n", charger->alignment);
}

static DEVICE_ATTR(alignment, 0444, p9221_show_alignment, NULL);

static ssize_t operating_freq_show(struct device *dev,
				   struct device_attribute *attr,
				   char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret = 0, val = 0;

	ret = p9221_ready_to_read(charger);
	if (!ret) {
		ret = charger->chip_get_op_freq(charger, &val);
		if (!ret)
			val = P9221_KHZ_TO_HZ(val);
	}

	if (ret)
		val = ret;

	return scnprintf(buf, PAGE_SIZE, "%d\n", val);
}

static DEVICE_ATTR_RO(operating_freq);

static ssize_t aicl_delay_ms_show(struct device *dev,
				  struct device_attribute *attr,
				  char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->aicl_delay_ms);
}

static ssize_t aicl_delay_ms_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret = 0;
	u32 t;

	ret = kstrtou32(buf, 10, &t);
	if (ret < 0)
		return ret;

	charger->aicl_delay_ms = t;

	return count;
}

static DEVICE_ATTR_RW(aicl_delay_ms);

static ssize_t aicl_icl_ua_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->aicl_icl_ua);
}

static ssize_t aicl_icl_ua_store(struct device *dev,
				 struct device_attribute *attr,
				 const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret = 0;
	u32 ua;

	ret = kstrtou32(buf, 10, &ua);
	if (ret < 0)
		return ret;

	charger->aicl_icl_ua = ua;

	return count;
}

static DEVICE_ATTR_RW(aicl_icl_ua);

static ssize_t ptmc_id_show(struct device *dev,
			    struct device_attribute *attr,
			    char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	p9382_get_ptmc_id_str(charger->ptmc_id_str, PAGE_SIZE, charger);
	return scnprintf(buf, PAGE_SIZE, "%s\n", charger->ptmc_id_str);
}

static DEVICE_ATTR_RO(ptmc_id);

static ssize_t features_store(struct device *dev,
                              struct device_attribute *attr,
                              const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	u64 id, ft;
	int ret;

	ret = sscanf(buf, "%llx:%llx", &id, &ft);
	if (ret != 2)
		return -EINVAL;

	pr_debug("%s: tx_id=%llx, ft=%llx", __func__, id, ft);

	if (id) {
		if (id != 1)
			feature_update_cache(&charger->chg_features, id, ft);
		/*
		 * disable prefill of feature cache on first use of the API,
		 * TODO: possibly clear the cache as well.
		 * NOTE: Protect this with a lock.
		 */
		if (charger->pdata->feat_compat_mode) {
			dev_info(charger->dev, "compat mode off\n");
			charger->pdata->feat_compat_mode = false;
		}
	} else {
		ret = feature_update_session(charger, ft);
		if (ret < 0)
			count = ret;
	}

	return count;
}

static ssize_t features_show(struct device *dev,
			     struct device_attribute *attr,
			     char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	struct p9221_charger_feature *chg_fts = &charger->chg_features;
	struct p9221_charger_feature_entry *entry = &chg_fts->entries[0];
	u64 session_features = chg_fts->session_features;
	int idx;
	ssize_t len = 0;

	if (!charger->wlc_dc_enabled)
		session_features &= ~WLCF_FAST_CHARGE;

	len += scnprintf(buf + len, PAGE_SIZE - len, "0:%llx\n",
			 session_features);

	for (idx = 0; idx < chg_fts->num_entries; idx++, entry++) {
		if (entry->quickid == 0 || entry->features == 0)
			continue;
		len += scnprintf(buf + len, PAGE_SIZE - len,
				 "%llx:%llx\n",
				 entry->quickid,
				 entry->features);
	}
	return len;
}

static DEVICE_ATTR_RW(features);

static ssize_t mitigate_threshold_show(struct device *dev,
				       struct device_attribute *attr,
				       char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%u\n", charger->mitigate_threshold);
}

static ssize_t mitigate_threshold_store(struct device *dev,
					struct device_attribute *attr,
					const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret;
	u8 threshold;

	ret = kstrtou8(buf, 0, &threshold);
	if (ret < 0)
		return ret;
	charger->mitigate_threshold = threshold;
	return count;
}

static DEVICE_ATTR_RW(mitigate_threshold);

/*
 * b/205193265 AP needs to wait for Cal-mode1 and mode2 to clear (calibration
 * to be complete) before attempting both authentication and re-negotiation.
 * The HAL API calls for authentication can check this node.
 */
static ssize_t wpc_ready_show(struct device *dev,
			    struct device_attribute *attr,
			    char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	/* Skip it on BPP */
	if (!p9221_is_epp(charger) || !charger->pdata->has_wlc_dc)
		return scnprintf(buf, PAGE_SIZE, "N\n");

	return scnprintf(buf, PAGE_SIZE, "%c\n",
			 p9412_is_calibration_done(charger) ? 'Y' : 'N');
}

static DEVICE_ATTR_RO(wpc_ready);

/* ------------------------------------------------------------------------ */
static ssize_t rx_lvl_show(struct device *dev,
			   struct device_attribute *attr,
			   char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	if (!charger->pdata->has_rtx)
		return -ENODEV;

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->rtx_csp);
}

static DEVICE_ATTR_RO(rx_lvl);

static ssize_t rtx_status_show(struct device *dev,
				     struct device_attribute *attr,
				     char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	static const char * const rtx_state_text[] = {
		"not support", "available", "active", "disabled" };
	int ext_bst_on = 0;

	if (!charger->pdata->has_rtx)
		charger->rtx_state = RTX_NOTSUPPORTED;

	if (p9221_is_online(charger)) {
		if (charger->ben_state || charger->rtx_reset_cnt)
			charger->rtx_state = RTX_ACTIVE;
		else
			charger->rtx_state = RTX_DISABLED;
	} else {
		if (charger->pdata->ben_gpio > 0)
			ext_bst_on = gpio_get_value_cansleep(charger->pdata->ben_gpio);
		if (ext_bst_on)
			charger->rtx_state = RTX_DISABLED;
		else
			charger->rtx_state = RTX_AVAILABLE;
	}

	return scnprintf(buf, PAGE_SIZE, "%s\n",
			 rtx_state_text[charger->rtx_state]);
}

static DEVICE_ATTR_RO(rtx_status);

static ssize_t is_rtx_connected_show(struct device *dev,
				     struct device_attribute *attr,
				     char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	u16 status_reg = 0;
	bool attached = 0;

	if (!charger->pdata->has_rtx)
		return -ENODEV;

	if (charger->ben_state)
		p9221_reg_read_16(charger, P9221_STATUS_REG, &status_reg);

	attached = status_reg & charger->ints.rx_connected_bit;

	return scnprintf(buf, PAGE_SIZE, "%s\n",
			 attached ? "connected" : "disconnect");
}

static DEVICE_ATTR_RO(is_rtx_connected);

static ssize_t rtx_err_show(struct device *dev,
			    struct device_attribute *attr,
			    char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->rtx_err);
}

static DEVICE_ATTR_RO(rtx_err);

static ssize_t qien_show(struct device *dev,
			 struct device_attribute *attr,
			 char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int value;

	if (charger->pdata->qien_gpio < 0)
		return -ENODEV;

	value = gpio_get_value_cansleep(charger->pdata->qien_gpio);

	return scnprintf(buf, PAGE_SIZE, "%d\n", value != 0);
}

static ssize_t qien_store(struct device *dev,
			  struct device_attribute *attr,
			  const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	if (charger->pdata->qien_gpio < 0)
		return -ENODEV;

	gpio_set_value_cansleep(charger->pdata->qien_gpio, buf[0] != '0');

	return count;
}
static DEVICE_ATTR_RW(qien);

static ssize_t qi_vbus_en_show(struct device *dev,
			       struct device_attribute *attr,
			       char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int value;

	if (charger->pdata->qi_vbus_en < 0)
		return -ENODEV;

	value = gpio_get_value_cansleep(charger->pdata->qi_vbus_en);

	return scnprintf(buf, PAGE_SIZE, "%d\n", value != 0);
}

static ssize_t qi_vbus_en_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int value;

	if (charger->pdata->qi_vbus_en < 0)
		return -ENODEV;

	value = (buf[0] != '0') ^ charger->pdata->qi_vbus_en_act_low;

	gpio_set_value_cansleep(charger->pdata->qi_vbus_en, value);

	return count;
}
static DEVICE_ATTR_RW(qi_vbus_en);

static ssize_t ext_ben_show(struct device *dev,
			    struct device_attribute *attr,
			    char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int value;

	if (charger->pdata->ext_ben_gpio < 0)
		return -ENODEV;

	value = gpio_get_value_cansleep(charger->pdata->ext_ben_gpio);

	return scnprintf(buf, PAGE_SIZE, "%d\n", value != 0);
}

static ssize_t ext_ben_store(struct device *dev,
			     struct device_attribute *attr,
			     const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	if (charger->pdata->ext_ben_gpio < 0)
		return -ENODEV;

	gpio_set_value_cansleep(charger->pdata->ext_ben_gpio, buf[0] != '0');

	return count;
}
static DEVICE_ATTR_RW(ext_ben);

static ssize_t rtx_sw_show(struct device *dev,
			   struct device_attribute *attr,
			   char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int value;

	if (charger->pdata->switch_gpio < 0)
		return -ENODEV;

	value = gpio_get_value_cansleep(charger->pdata->switch_gpio);

	return scnprintf(buf, PAGE_SIZE, "%d\n", value != 0);
}

static ssize_t rtx_sw_store(struct device *dev,
			    struct device_attribute *attr,
			    const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	if (charger->pdata->switch_gpio < 0)
		return -ENODEV;

	/* TODO: better test on rX mode */
	if (charger->online) {
		dev_err(&charger->client->dev, "invalid rX state");
		return -EINVAL;
	}

	gpio_set_value_cansleep(charger->pdata->switch_gpio, buf[0] != '0');

	return count;
}

static DEVICE_ATTR_RW(rtx_sw);

static ssize_t fw_rev_show(struct device *dev,
			   struct device_attribute *attr, char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%04x\n", charger->fw_rev);
}

static DEVICE_ATTR_RO(fw_rev);

static ssize_t p9382_show_rtx_boost(struct device *dev,
				    struct device_attribute *attr,
				    char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->ben_state);
}

/* assume that we have 2 GPIO to turn on the boost */
static int p9382_rtx_enable(struct p9221_charger_data *charger, bool enable)
{
	int ret = 0;

	/*
	 * TODO: deprecate the support for rTX on whitefin2 or use a DT entry
	 * to ignore the votable and use ben+switch
	 */
	if (!charger->chg_mode_votable)
		charger->chg_mode_votable =
			gvotable_election_get_handle(GBMS_MODE_VOTABLE);
	if (charger->chg_mode_votable) {
		ret = gvotable_cast_long_vote(charger->chg_mode_votable,
					      P9221_WLC_VOTER,
					      GBMS_CHGR_MODE_WLC_TX, enable);
		return ret;
	}

	if (charger->pdata->ben_gpio >= 0)
		gpio_set_value_cansleep(charger->pdata->ben_gpio, enable);
	if (charger->pdata->switch_gpio >= 0)
		gpio_set_value_cansleep(charger->pdata->switch_gpio, enable);

	/* some systems provide additional boost_gpio for charging level */
	if (charger->pdata->boost_gpio >= 0)
		gpio_set_value_cansleep(charger->pdata->boost_gpio, enable);

	return (charger->pdata->ben_gpio < 0 &&
		charger->pdata->switch_gpio < 0) ? -ENODEV : 0;
}

static int p9382_ben_cfg(struct p9221_charger_data *charger, int cfg)
{
	const int ben_gpio = charger->pdata->ben_gpio;
	const int switch_gpio = charger->pdata->switch_gpio;

	dev_info(&charger->client->dev, "ben_cfg: %d->%d (ben=%d, switch=%d)",
		 charger->ben_state, cfg, ben_gpio, switch_gpio);

	switch (cfg) {
	case RTX_BEN_DISABLED:
		if (charger->ben_state == RTX_BEN_ON)
			p9382_rtx_enable(charger, false);
		else if (ben_gpio == RTX_BEN_ENABLED)
			gpio_set_value_cansleep(ben_gpio, 0);
		charger->ben_state = cfg;
		break;
	case RTX_BEN_ENABLED:
		charger->ben_state = cfg;
		if (ben_gpio >= 0)
			gpio_set_value_cansleep(ben_gpio, 1);
		break;
	case RTX_BEN_ON:
		charger->ben_state = cfg;
		p9382_rtx_enable(charger, true);
		break;
	default:
		return -EINVAL;
	}

	return 0;
}

static ssize_t p9382_set_rtx_boost(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	const int state = buf[0] - '0';
	int ret;

	/* always ok to disable */
	if (state && charger->online && !charger->ben_state) {
		dev_err(&charger->client->dev, "invalid rX state");
		return -ENODEV;
	}

	/* 0 -> BEN_DISABLED, 1 -> BEN_ON */
	ret = p9382_ben_cfg(charger, state);
	if (ret < 0)
		count = ret;

	return count;
}

static DEVICE_ATTR(rtx_boost, 0644, p9382_show_rtx_boost, p9382_set_rtx_boost);

static ssize_t p9221_show_chg_stats(struct device *dev,
				    struct device_attribute *attr,
				    char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int i, len = -ENODATA;

	mutex_lock(&charger->stats_lock);

	if (charger->chg_data.cur_soc < 0)
		goto enodata_done;

	len = p9221_chg_data_head_dump(buf, PAGE_SIZE, &charger->chg_data);
	if (len < PAGE_SIZE)
		buf[len++] = '\n';

	len += p9221_adapter_capabilities_dump(&buf[len], PAGE_SIZE - len, &charger->chg_data);
	if (len < PAGE_SIZE)
		buf[len++] = '\n';

	for (i = 0; i < WLC_SOC_STATS_LEN; i++) {
		if (charger->chg_data.soc_data[i].elapsed_time == 0)
			continue;
		len += p9221_soc_data_dump(&buf[len], PAGE_SIZE - len,
					   &charger->chg_data, i);
		if (len < PAGE_SIZE)
			buf[len++] = '\n';
	}

enodata_done:
	mutex_unlock(&charger->stats_lock);
	return len;
}

static ssize_t p9221_ctl_chg_stats(struct device *dev,
                                  struct device_attribute *attr,
                                  const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	if (count < 1)
		return -ENODATA;

	mutex_lock(&charger->stats_lock);
	switch (buf[0]) {
	case 0:
	case '0':
		p9221_charge_stats_init(&charger->chg_data);
		break;
	}
	mutex_unlock(&charger->stats_lock);

	return count;
}

static DEVICE_ATTR(charge_stats, 0644, p9221_show_chg_stats, p9221_ctl_chg_stats);

static int p9382_disable_dcin_en(struct p9221_charger_data *charger, bool enable)
{
	int ret;

	if (!charger->disable_dcin_en_votable)
		charger->disable_dcin_en_votable =
			gvotable_election_get_handle("DC_SUSPEND");
	if (!charger->disable_dcin_en_votable)
		return 0;

	ret = gvotable_cast_bool_vote(charger->disable_dcin_en_votable,
				      P9221_WLC_VOTER, enable);
	if (ret == 0)
		return 0;

	dev_err(&charger->client->dev, "Could not vote DISABLE_DCIN_EN (%d)\n", ret);
	return ret;
}

static int p9382_set_rtx(struct p9221_charger_data *charger, bool enable)
{
	int ret = 0, tx_icl = -1;

	if ((enable && charger->ben_state) || (!enable && !charger->ben_state)) {
		logbuffer_prlog(charger->rtx_log, "RTx is %s\n", enable ? "enabled" : "disabled");
		return 0;
	}

	mutex_lock(&charger->rtx_lock);

	if (enable == 0) {
		if (charger->is_rtx_mode) {
			ret = charger->chip_tx_mode_en(charger, false);
			charger->is_rtx_mode = false;
		}
		ret = p9382_ben_cfg(charger, RTX_BEN_DISABLED);
		if (ret < 0)
			goto error;

		ret = p9382_disable_dcin_en(charger, false);
		if (ret)
			dev_err(&charger->client->dev,
				"fail to enable dcin, ret=%d\n", ret);

		logbuffer_log(charger->rtx_log, "disable rtx\n");

		goto done;
	} else {
		logbuffer_log(charger->rtx_log, "enable rtx");
		/* Check if there is any one vote disabled */
		if (charger->tx_icl_votable)
			tx_icl = gvotable_get_current_int_vote(
					charger->tx_icl_votable);
		if (tx_icl == 0) {
			dev_err(&charger->client->dev, "rtx be disabled\n");
			logbuffer_log(charger->rtx_log, "rtx be disabled\n");
			charger->rtx_reset_cnt = 0;
			goto done;
		}

		/*
		 * Check if WLC online
		 * NOTE: when used CHARGER_MODE will also prevent this.
		 */
		if (charger->online) {
			dev_err(&charger->client->dev,
				"rTX is not allowed during WLC\n");
			logbuffer_log(charger->rtx_log,
				      "rTX is not allowed during WLC\n");
			charger->rtx_reset_cnt = 0;
			goto done;
		}

		/*
		 * DCIN_EN votable will not be available on all systems.
		 * if it is there, it is needed.
		 */
		ret = p9382_disable_dcin_en(charger, true);
		if (ret) {
			dev_err(&charger->client->dev, "cannot enable rTX mode %d\n", ret);
			goto error;
		}

		charger->com_busy = 0;
		charger->rtx_csp = 0;
		charger->rtx_err = RTX_NO_ERROR;
		charger->is_rtx_mode = false;

		ret = p9382_ben_cfg(charger, RTX_BEN_ON);
		if (ret < 0)
			goto error;

		msleep(10);

		ret = charger->chip_tx_mode_en(charger, true);
		if (ret < 0) {
			dev_err(&charger->client->dev,
				"cannot enter rTX mode (%d)\n", ret);
			logbuffer_log(charger->rtx_log,
				      "cannot enter rTX mode (%d)\n", ret);
			p9382_ben_cfg(charger, RTX_BEN_DISABLED);

			ret = p9382_disable_dcin_en(charger, false);

			charger->is_rtx_mode = false;
			goto error;
		}

		ret = p9221_enable_interrupts(charger);
		if (ret)
			dev_err(&charger->client->dev,
				"Could not enable interrupts: %d\n", ret);

		/* configure TX_ICL */
		if (charger->tx_icl_votable)
			tx_icl = gvotable_get_current_int_vote(
					charger->tx_icl_votable);

		if ((tx_icl > 0) &&
		    (tx_icl != P9221_MA_TO_UA(P9382A_RTX_ICL_MAX_MA))) {
			ret = charger->chip_set_tx_ilim(charger, tx_icl);
			if (ret == 0)
				logbuffer_log(charger->rtx_log,
					      "set Tx current limit: %dmA",
					      tx_icl);
			else
				dev_err(&charger->client->dev,
					"Could not set Tx current limit: %d\n",
					ret);
		}
		goto done;
	}
error:
	if (charger->rtx_reset_cnt > 0) {
		charger->rtx_err = RTX_HARD_OCP;
		charger->rtx_reset_cnt = 0;
	}
done:
	if (charger->rtx_reset_cnt == 0)
		schedule_work(&charger->uevent_work);

	if (enable && charger->is_rtx_mode && !charger->rtx_wakelock) {
		pm_stay_awake(charger->dev);
		charger->rtx_wakelock = true;
	} else if (!enable && charger->rtx_wakelock) {
		pm_relax(charger->dev);
		charger->rtx_wakelock = false;
	} else {
		dev_info(&charger->client->dev, "%s RTx(%d), rtx_wakelock=%d\n",
			 enable ? "enable" : "disable",
			 charger->is_rtx_mode, charger->rtx_wakelock);
	}
	dev_dbg(&charger->client->dev, "%s RTx(%d), rtx_wakelock=%d\n",
		enable ? "enable" : "disable", charger->is_rtx_mode, charger->rtx_wakelock);

	mutex_unlock(&charger->rtx_lock);

	return ret;
}

#define P9412_RTX_OCP_THRES_MA		900
static int p9412_check_rtx_ocp(struct p9221_charger_data *chgr)
{
	int ret, cnt, retry, ocp_count = 0, current_now, chk_ms, total_delay;
	u16 status_reg;

	total_delay = chgr->rtx_total_delay > 0 ? chgr->rtx_total_delay : 3000;
	chk_ms = chgr->rtx_ocp_chk_ms > 0 ? chgr->rtx_ocp_chk_ms : 20;
	retry = (total_delay / chk_ms > 0) ? (total_delay / chk_ms) : 1;

	logbuffer_log(chgr->rtx_log, "use rtx_ocp_chk_ms=%d retry=%d", chk_ms, retry);

	for (cnt = 0; cnt < retry; cnt++) {
		if (!chgr->ben_state)
			return -EIO;
		/* check if rx_is_connected: if yes, goto 7V */
		ret = chgr->reg_read_16(chgr, P9221_STATUS_REG, &status_reg);
		if (ret < 0) {
			logbuffer_log(chgr->rtx_log, "ioerr disable RTx(%d)", ret);
			return -EIO;
		}
		if (status_reg & chgr->ints.rx_connected_bit) {
			logbuffer_log(chgr->rtx_log, "rx is connected, goto 7V");
			return 0;
		}
		/* check if (ocp_cnt > 2): if yes, disable rtx */
		ret = chgr->chip_get_iout(chgr, &current_now);
		if (ret == 0 && current_now > P9412_RTX_OCP_THRES_MA) {
			ocp_count++;
			logbuffer_log(chgr->rtx_log, "cnt=%d,current_now=%d,ocp_count=%d",
				      cnt, current_now, ocp_count);
		}
		if (ret < 0) {
			logbuffer_log(chgr->rtx_log, "iout disable RTx(%d)", ret);
			return -EINVAL;
		}
		if (ocp_count > 2 || current_now == 0) {
			logbuffer_log(chgr->rtx_log, "ocp_count=%d current_now=%d disable RTx",
				      ocp_count, current_now);
			return -EINVAL;
		}
		usleep_range(chk_ms * USEC_PER_MSEC, (chk_ms + 2) * USEC_PER_MSEC);
	}

	return 0;
}

static void p9412_chk_rtx_ocp_work(struct work_struct *work)
{
	struct p9221_charger_data *chgr = container_of(work,
			struct p9221_charger_data, chk_rtx_ocp_work.work);
	int ret;

	/* check TX OCP before enable 7V */
	ret = p9412_check_rtx_ocp(chgr);
	if (!chgr->ben_state)
		return;
	if (ret < 0) {
		p9382_set_rtx(chgr, false);
		return;
	}

	ret = chgr->reg_write_8(chgr, P9412_APBSTPING_REG, P9412_APBSTPING_7V);
	ret |= chgr->reg_write_8(chgr, P9412_APBSTCONTROL_REG, P9412_APBSTPING_7V);
	if (ret == 0) {
		schedule_delayed_work(&chgr->rtx_work, msecs_to_jiffies(P9382_RTX_TIMEOUT_MS));
	} else {
		logbuffer_log(chgr->rtx_log, "Failed to configure Ext-Boost Vout registers(%d)",
			      ret);
		p9382_set_rtx(chgr, false);
	}
}

static ssize_t rtx_show(struct device *dev,
			struct device_attribute *attr,
			char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->ben_state);
}

/* write 1 to enable boost & switch, write 0 to 0x34, wait for 0x4c==0x4
 * write 0 to write 0x80 to 0x4E, wait for 0x4c==0, disable boost & switch
 */
static ssize_t rtx_store(struct device *dev,
		       struct device_attribute *attr,
		       const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);
	int ret;

	if (buf[0] == '0') {
		logbuffer_prlog(charger->rtx_log, "battery share off");
		mutex_lock(&charger->rtx_lock);
		charger->rtx_reset_cnt = 0;
		mutex_unlock(&charger->rtx_lock);
		ret = p9382_set_rtx(charger, false);
		cancel_delayed_work_sync(&charger->rtx_work);
		cancel_delayed_work_sync(&charger->chk_rtx_ocp_work);
	} else if (buf[0] == '1') {
		logbuffer_prlog(charger->rtx_log, "battery share on");
		mutex_lock(&charger->rtx_lock);
		charger->rtx_reset_cnt = 0;
		mutex_unlock(&charger->rtx_lock);
		ret = p9382_set_rtx(charger, true);
	} else {
		return -EINVAL;
	}

	if (ret == 0)
		return count;
	else
		return ret;
}

static DEVICE_ATTR_RW(rtx);


static ssize_t has_wlc_dc_show(struct device *dev,
			struct device_attribute *attr,
			char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->pdata->has_wlc_dc);
}

/* write 1 to enable boost & switch, write 0 to 0x34, wait for 0x4c==0x4
 * write 0 to write 0x80 to 0x4E, wait for 0x4c==0, disable boost & switch
 */
static ssize_t has_wlc_dc_store(struct device *dev,
		       struct device_attribute *attr,
		       const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	charger->pdata->has_wlc_dc = buf[0] == '1';
	return count;
}

static DEVICE_ATTR_RW(has_wlc_dc);

static ssize_t log_current_filtered_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	return scnprintf(buf, PAGE_SIZE, "%d\n", charger->log_current_filtered);
}

/* write '1' to enable logging */
static ssize_t log_current_filtered_store(struct device *dev,
					  struct device_attribute *attr,
					  const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	charger->log_current_filtered = buf[0] == '1';
	return count;
}

static DEVICE_ATTR_RW(log_current_filtered);


static struct attribute *rtx_attributes[] = {
	&dev_attr_rtx_sw.attr,
	&dev_attr_rtx_boost.attr,
	&dev_attr_rtx.attr,
	&dev_attr_rtx_status.attr,
	&dev_attr_is_rtx_connected.attr,
	&dev_attr_rx_lvl.attr,
	&dev_attr_rtx_err.attr,
	NULL
};

static const struct attribute_group rtx_attr_group = {
	.attrs		= rtx_attributes,
};

static struct attribute *p9221_attributes[] = {
	&dev_attr_version.attr,
	&dev_attr_status.attr,
	&dev_attr_addr.attr,
	&dev_attr_count.attr,
	&dev_attr_data.attr,
	&dev_attr_ccreset.attr,
	&dev_attr_txbusy.attr,
	&dev_attr_txdone.attr,
	&dev_attr_txlen.attr,
	&dev_attr_rxlen.attr,
	&dev_attr_rxdone.attr,
	&dev_attr_icl_ramp_ua.attr,
	&dev_attr_icl_ramp_delay_ms.attr,
	&dev_attr_force_epp.attr,
	&dev_attr_dc_icl_bpp.attr,
	&dev_attr_dc_icl_epp.attr,
	&dev_attr_alignment.attr,
	&dev_attr_aicl_delay_ms.attr,
	&dev_attr_aicl_icl_ua.attr,
	&dev_attr_operating_freq.attr,
	&dev_attr_ptmc_id.attr,
	&dev_attr_ext_ben.attr,
	&dev_attr_qi_vbus_en.attr,
	&dev_attr_has_wlc_dc.attr,
	&dev_attr_log_current_filtered.attr,
	&dev_attr_charge_stats.attr,
	&dev_attr_fw_rev.attr,
	&dev_attr_authtype.attr,
	&dev_attr_features.attr,
	&dev_attr_mitigate_threshold.attr,
	&dev_attr_wpc_ready.attr,
	&dev_attr_qien.attr,
	NULL
};

static ssize_t p9221_rxdata_read(struct file *filp, struct kobject *kobj,
				 struct bin_attribute *bin_attr,
				 char *buf, loff_t pos, size_t size)
{
	struct p9221_charger_data *charger;
	charger = dev_get_drvdata(container_of(kobj, struct device, kobj));

	memcpy(buf, &charger->rx_buf[pos], size);
	charger->rx_done = false;
	return size;
}

static struct bin_attribute bin_attr_rxdata = {
	.attr = {
		.name = "rxdata",
		.mode = 0400,
	},
	.read = p9221_rxdata_read,
	.size = P9221R5_DATA_RECV_BUF_SIZE,
};

static ssize_t p9221_txdata_read(struct file *filp, struct kobject *kobj,
				 struct bin_attribute *bin_attr,
				 char *buf, loff_t pos, size_t size)
{
	struct p9221_charger_data *charger;
	charger = dev_get_drvdata(container_of(kobj, struct device, kobj));

	memcpy(buf, &charger->tx_buf[pos], size);
	return size;
}

static ssize_t p9221_txdata_write(struct file *filp, struct kobject *kobj,
				  struct bin_attribute *bin_attr,
				  char *buf, loff_t pos, size_t size)
{
	struct p9221_charger_data *charger;
	charger = dev_get_drvdata(container_of(kobj, struct device, kobj));

	memcpy(&charger->tx_buf[pos], buf, size);
	return size;
}

static struct bin_attribute bin_attr_txdata = {
	.attr = {
		.name = "txdata",
		.mode = 0600,
	},
	.read = p9221_txdata_read,
	.write = p9221_txdata_write,
	.size  = P9221R5_DATA_SEND_BUF_SIZE,
};

static struct bin_attribute *p9221_bin_attributes[] = {
	&bin_attr_txdata,
	&bin_attr_rxdata,
	NULL,
};

static const struct attribute_group p9221_attr_group = {
	.attrs		= p9221_attributes,
	.bin_attrs	= p9221_bin_attributes,
};

static void print_current_samples(struct p9221_charger_data *charger,
					u32 *iout_val, int count)
{
	int i;
	char temp[P9221R5_OVER_CHECK_NUM * 9 + 1] = { 0 };

	for (i = 0; i < count ; i++)
		scnprintf(temp + i * 9, sizeof(temp) - i * 9,
			  "%08x ", iout_val[i]);

	dev_info(&charger->client->dev, "OVER IOUT_SAMPLES: %s\n", temp);
}

/*
 * Number of times to poll the status to see if the current limit condition
 * was transient or not.
 */
static void p9221_over_handle(struct p9221_charger_data *charger,
			      u16 irq_src)
{
	u8 reason = 0;
	int i;
	int ret;
	int ovc_count = 0;
	u32 iout_val[P9221R5_OVER_CHECK_NUM] = { 0 };

	dev_err(&charger->client->dev, "Received OVER INT: %02x\n", irq_src);

	if (irq_src & charger->ints.over_volt_bit) {
		reason = P9221_EOP_OVER_VOLT;
		goto send_eop;
	}

	if (irq_src & charger->ints.over_temp_bit) {
		reason = P9221_EOP_OVER_TEMP;
		goto send_eop;
	}

	if ((irq_src & charger->ints.over_uv_bit) && !(irq_src & charger->ints.over_curr_bit))
		return;

	/* Overcurrent, reduce ICL and poll to absorb any transients */

	if (charger->dc_icl_votable) {
		int icl;

		icl = gvotable_get_current_int_vote(charger->dc_icl_votable);
		if (icl < 0) {
			dev_err(&charger->client->dev,
				"Failed to read ICL (%d)\n", icl);
		} else if (icl > OVC_BACKOFF_LIMIT) {
			icl -= OVC_BACKOFF_AMOUNT;

			ret = gvotable_cast_int_vote(charger->dc_icl_votable,
						     P9221_OCP_VOTER,
						     icl, true);
			dev_err(&charger->client->dev,
				"Reduced ICL to %d (%d)\n", icl, ret);
		}
	}

	reason = P9221_EOP_OVER_CURRENT;
	for (i = 0; i < P9221R5_OVER_CHECK_NUM; i++) {
		ret = p9221_clear_interrupts(charger,
					     irq_src & charger->ints.stat_limit_mask);
		msleep(50);
		if (ret)
			continue;

		ret = charger->chip_get_iout(charger, &iout_val[i]);
		if (ret) {
			dev_err(&charger->client->dev,
				"Failed to read iout[%d]: %d\n", i, ret);
			continue;
		} else {
			iout_val[i] = P9221_MA_TO_UA(iout_val[i]);

			if (iout_val[i] > OVC_THRESHOLD)
				ovc_count++;
		}

		ret = p9221_reg_read_16(charger, P9221_STATUS_REG, &irq_src);
		if (ret) {
			dev_err(&charger->client->dev,
				"Failed to read status: %d\n", ret);
			continue;
		}

		if ((irq_src & charger->ints.over_curr_bit) == 0) {
			print_current_samples(charger, iout_val, i + 1);
			dev_info(&charger->client->dev,
				 "OVER condition %04x cleared after %d tries\n",
				 irq_src, i);
			return;
		}

		dev_err(&charger->client->dev,
			"OVER status is still %04x, retry\n", irq_src);
	}

	if (ovc_count < OVC_LIMIT) {
		print_current_samples(charger, iout_val,
				      P9221R5_OVER_CHECK_NUM);
		dev_info(&charger->client->dev,
			 "ovc_threshold=%d, ovc_count=%d, ovc_limit=%d\n",
			 OVC_THRESHOLD, ovc_count, OVC_LIMIT);
		return;
	}

send_eop:
	dev_err(&charger->client->dev,
		"OVER is %04x, sending EOP %d\n", irq_src, reason);

	ret = charger->chip_send_eop(charger, reason);
	if (ret)
		dev_err(&charger->client->dev,
			"Failed to send EOP %d: %d\n", reason, ret);
}

static void p9382_txid_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, txid_work.work);
	int ret = 0;
	bool attached = 0;
	u16 status_reg;
	const u16 rx_connected_bit = charger->ints.rx_connected_bit;

	/* check rx_is_connected */
	ret = p9221_reg_read_16(charger, P9221_STATUS_REG, &status_reg);
	attached = (ret == 0) ? (status_reg & rx_connected_bit) : 0;
	if (!attached)
		return;

	if (charger->ints.pppsent_bit && charger->com_busy) {
		if (charger->com_busy >= COM_BUSY_MAX) {
			if (p9221_send_ccreset(charger) == 0)
				charger->com_busy = 0;
		} else {
			charger->com_busy += 1;
		}
		schedule_delayed_work(&charger->txid_work,
				      msecs_to_jiffies(TXID_SEND_DELAY_MS));
		logbuffer_log(charger->rtx_log,
			      "com_busy=%d, reschedule txid_work()",
			      charger->com_busy);
		return;
	}

	ret = charger->chip_send_txid(charger);
	if (!ret) {
		p9221_hex_str(&charger->tx_buf[1], FAST_SERIAL_ID_SIZE,
			      charger->fast_id_str,
			      sizeof(charger->fast_id_str), false);
		dev_info(&charger->client->dev, "Fast serial ID send(%s)\n",
			 charger->fast_id_str);
		charger->com_busy += 1;
		if (charger->send_txid_cnt > 0) {
			charger->send_txid_cnt--;
			schedule_delayed_work(&charger->txid_work,
					      msecs_to_jiffies(TXID_SEND_AGAIN_DELAY_MS));
		}
	}
}

static void p9xxx_reset_rtx_for_ocp(struct p9221_charger_data *charger)
{
	int ext_bst_on = 0;

	mutex_lock(&charger->rtx_lock);
	charger->rtx_reset_cnt += 1;

	if (charger->rtx_reset_cnt >= RTX_RESET_COUNT_MAX) {
		if (charger->rtx_reset_cnt == RTX_RESET_COUNT_MAX)
			charger->rtx_err = RTX_HARD_OCP;
		charger->rtx_reset_cnt = 0;
	}
	mutex_unlock(&charger->rtx_lock);

	charger->is_rtx_mode = false;
	p9382_set_rtx(charger, false);

	msleep(REENABLE_RTX_DELAY);

	if (charger->pdata->ben_gpio > 0)
		ext_bst_on = gpio_get_value_cansleep(charger->pdata->ben_gpio);
	if (ext_bst_on)
		return;

	if (charger->rtx_reset_cnt) {
		dev_info(&charger->client->dev, "re-enable RTx mode, cnt=%d\n", charger->rtx_reset_cnt);
		logbuffer_log(charger->rtx_log, "re-enable RTx mode, cnt=%d\n", charger->rtx_reset_cnt);
		p9382_set_rtx(charger, true);
		schedule_work(&charger->uevent_work);
	}
}

static void p9xxx_rtx_reset_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, rtx_reset_work);

	p9xxx_reset_rtx_for_ocp(charger);
}

static void p9382_rtx_work(struct work_struct *work)
{
	u8 mode_reg = 0;
	int ret = 0;
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, rtx_work.work);

	if (!charger->ben_state)
		return;

	/* Check if RTx mode is auto turn off */
	ret = charger->chip_get_sys_mode(charger, &mode_reg);
	if ((ret == 0) && (mode_reg & P9XXX_SYS_OP_MODE_TX_MODE))
		goto reschedule;

	dev_info(&charger->client->dev, "is_rtx_on: ben=%d, mode=%02x, ret=%d",
		 charger->ben_state, mode_reg, ret);
	logbuffer_log(charger->rtx_log, "is_rtx_on: ben=%d, mode=%02x, ret=%d",
		      charger->ben_state, mode_reg, ret);

	p9xxx_reset_rtx_for_ocp(charger);

reschedule:
	schedule_delayed_work(&charger->rtx_work,
			      msecs_to_jiffies(P9382_RTX_TIMEOUT_MS));
}

/* Handler for rtx mode */
static void rtx_irq_handler(struct p9221_charger_data *charger, u16 irq_src)
{
	int ret;
	u8 mode_reg, csp_reg;
	u16 status_reg;
	bool attached = 0;
	const u16 mode_changed_bit = charger->ints.mode_changed_bit;
	const u16 pppsent_bit = charger->ints.pppsent_bit;
	const u16 hard_ocp_bit = charger->ints.hard_ocp_bit;
	const u16 tx_conflict_bit = charger->ints.tx_conflict_bit;
	const u16 rx_connected_bit = charger->ints.rx_connected_bit;
	const u16 csp_bit = charger->ints.csp_bit;
	const u16 ocp_ping_bit = charger->ints.ocp_ping_bit;

	if (irq_src & mode_changed_bit) {
		ret = charger->chip_get_sys_mode(charger, &mode_reg);
		if (ret) {
			dev_err(&charger->client->dev,
				"Failed to read P9221_SYSTEM_MODE_REG: %d\n",
				ret);
			return;
		}
		if (mode_reg == P9XXX_SYS_OP_MODE_TX_MODE) {
			charger->is_rtx_mode = true;
			cancel_delayed_work_sync(&charger->rtx_work);
			if (!charger->pdata->apbst_en || charger->pdata->hw_ocp_det)
				schedule_delayed_work(&charger->rtx_work,
						      msecs_to_jiffies(P9382_RTX_TIMEOUT_MS));
		}
		dev_info(&charger->client->dev,
			 "P9221_SYSTEM_MODE_REG reg: %02x\n",
			 mode_reg);
		logbuffer_log(charger->rtx_log,
			      "SYSTEM_MODE_REG=%02x", mode_reg);
	}

	ret = p9221_reg_read_16(charger, P9221_STATUS_REG, &status_reg);
	if (ret) {
		dev_err(&charger->client->dev,
			"failed to read P9221_STATUS_REG reg: %d\n",
			ret);
		return;
	}

	if (irq_src & pppsent_bit)
		charger->com_busy = 0;

	if (irq_src & (hard_ocp_bit | tx_conflict_bit | ocp_ping_bit)) {
		if (irq_src & hard_ocp_bit)
			charger->rtx_err = RTX_HARD_OCP;
		else if (irq_src & tx_conflict_bit)
			charger->rtx_err = RTX_TX_CONFLICT;

		logbuffer_prlog(charger->rtx_log, "rtx_err=%d, STATUS_REG=%04x",
				charger->rtx_err, status_reg);

		cancel_delayed_work_sync(&charger->rtx_work);
		if (charger->rtx_err == RTX_HARD_OCP) {
			charger->rtx_err = 0;
			schedule_work(&charger->rtx_reset_work);
		} else {
			charger->is_rtx_mode = false;
			p9382_set_rtx(charger, false);
		}
	}

	if (irq_src & rx_connected_bit) {
		attached = status_reg & rx_connected_bit;
		logbuffer_log(charger->rtx_log,
			      "Rx is %s. STATUS_REG=%04x",
			      attached ? "connected" : "disconnect",
			      status_reg);
		schedule_work(&charger->uevent_work);
		if (attached) {
			cancel_delayed_work_sync(&charger->txid_work);
			charger->send_txid_cnt = 2;
			schedule_delayed_work(&charger->txid_work,
					msecs_to_jiffies(TXID_SEND_DELAY_MS));
		} else {
			cancel_delayed_work_sync(&charger->txid_work);
			charger->send_txid_cnt = 0;
			charger->rtx_csp = 0;
			charger->com_busy = 0;
		}
	}

	if (irq_src & csp_bit) {
		ret = p9221_reg_read_8(charger, charger->reg_csp_addr, &csp_reg);
		if (ret) {
			logbuffer_log(charger->rtx_log, "failed to read CSP_REG reg: %d", ret);
		} else {
			charger->rtx_csp = csp_reg;
			schedule_work(&charger->uevent_work);
		}
	}
}


#ifdef CONFIG_DC_RESET
/*
 * DC reset code uses a flag in the charger to initiate a hard reset of the
 * WLC chip after a power loss. This is (was?) needed for p9221 to handle
 * partial and/or rapid entry/exit from the field that could cause firmware
 * to become erratic.
 */
static bool p9221_dc_reset_needed(struct p9221_charger_data *charger,
				  u16 irq_src)
{
	/*
	 * It is suspected that p9221 misses to set the interrupt status
	 * register occasionally. Evaluate spurious interrupt case for
	 * dc reset as well.
	 */
	if (charger->pdata->needs_dcin_reset == P9221_WC_DC_RESET_MODECHANGED &&
	    (irq_src & charger->ints.mode_changed_bit || !irq_src)) {
		u8 mode_reg = 0;
		int res;

		res = charger->chip_get_sys_mode(charger, &mode_reg);
		if (res < 0) {
			dev_err(&charger->client->dev,
				"Failed to read P9221_SYSTEM_MODE_REG: %d\n",
				res);
			/*
			 * p9221_reg_read_n returns ENODEV for ENOTCONN as well.
			 * Signal dc_reset when register read fails with the
			 * above reasons.
			 */
			return res == -ENODEV;
		}

		dev_info(&charger->client->dev,
			 "P9221_SYSTEM_MODE_REG reg: %02x\n", mode_reg);
		return !(mode_reg == P9XXX_SYS_OP_MODE_WPC_EXTD ||
			 mode_reg == P9XXX_SYS_OP_MODE_PROPRIETARY ||
			 mode_reg == P9XXX_SYS_OP_MODE_WPC_BASIC);
	}

	if (charger->pdata->needs_dcin_reset == P9221_WC_DC_RESET_VOUTCHANGED &&
	    irq_src & charger->ints.vout_changed_bit) {
		u16 status_reg = 0;
		int res;

		res = p9221_reg_read_16(charger, P9221_STATUS_REG, &status_reg);
		if (res < 0) {
			dev_err(&charger->client->dev,
				"Failed to read P9221_STATUS_REG: %d\n", res);
			return res == -ENODEV ? true : false;
		}

		dev_info(&charger->client->dev,
			 "P9221_STATUS_REG reg: %04x\n", status_reg);
		return !(status_reg & charger->ints.vout_changed_bit);
	}

	return false;
}

static void p9221_check_dc_reset(struct p9221_charger_data *charger,
				    u16 irq_src)
{
	union power_supply_propval val = {.intval = 1};
	int res;

	if (!p9221_dc_reset_needed(charger, irq_src))
		return;

	if (!charger->dc_psy)
		charger->dc_psy = power_supply_get_by_name("dc");
	if (charger->dc_psy) {
		/* Signal DC_RESET when wireless removal is sensed. */
		res = power_supply_set_property(charger->dc_psy,
					POWER_SUPPLY_PROP_DC_RESET,
					&val);
	} else {
		res = -ENODEV;
	}

	if (res < 0)
		dev_err(&charger->client->dev,
			"unable to set DC_RESET, ret=%d",
			res);
}
#else
static void p9221_check_dc_reset(struct p9221_charger_data *charger,
				 u16 irq_src)
{

}
#endif

static void p9221_handle_pp(struct p9221_charger_data *charger)
{
	u8 tmp;
	u8 buff[sizeof(charger->pp_buf)];
	char bufstr[sizeof(charger->pp_buf) * 3 + 1];
	int msg_len;
	int res;

	res = p9xxx_chip_get_pp_buf(charger, buff, sizeof(buff));
	if (res) {
		dev_err(&charger->client->dev, "Failed to read PP: %d\n", res);
		return;
	}

	/* WPC 1.2.4: 5.2.2.4.1 */
	switch (buff[0]) {
	case 0x00 ... 0x1F:
		msg_len = 1 + (buff[0] - 0) / 32;
		break;
	case 0x20 ... 0x7F:
		msg_len = 2 + (buff[0] - 32) / 16;
		break;
	case 0x80 ... 0xDF:
		msg_len = 8 + (buff[0] - 128) / 8;
		break;
	case 0xE0 ... 0xFF:
		msg_len = 20 + (buff[0] - 224) / 4;
		break;
	}

	/* len is the length of the data + 1 for header. (cksum not supplied) */
	p9221_hex_str(buff, msg_len + 1, bufstr, sizeof(bufstr), false);
	dev_info(&charger->client->dev, "Received PP: %s\n", bufstr);
	logbuffer_log(charger->log, "Received PP: %s", bufstr);

	if ((buff[0] == CHARGE_STATUS_PACKET_HEADER) &&
	    (buff[1] == PP_TYPE_POWER_CONTROL) &&
	    (buff[2] == PP_SUBTYPE_SOC)) {
		u8 crc = p9221_crc8(&buff[1], CHARGE_STATUS_PACKET_SIZE - 1,
				    CRC8_INIT_VALUE);
		if (buff[4] != crc) {
			dev_err(&charger->client->dev, "PP CSP CRC mismatch\n");
			return;
		}
		charger->rtx_csp = buff[3] / 2;
		dev_info(&charger->client->dev, "Received Tx's soc=%d\n",
			 charger->rtx_csp);
		schedule_work(&charger->uevent_work);
		return;
	}

	/*
	 * We only care about 0x4F proprietary packets.  Don't touch pp_buf
	 * if there is no match.
	 */
	if (buff[0] != 0x4f)
		return;
	memcpy(charger->pp_buf, buff, sizeof(charger->pp_buf));
	charger->pp_buf_valid = 1;

	/* Check if charging on a Tx phone */
	tmp = charger->pp_buf[4] & ACCESSORY_TYPE_MASK;
	charger->chg_on_rtx = (tmp == ACCESSORY_TYPE_PHONE);
	dev_info(&charger->client->dev, "chg_on_rtx=%d\n", charger->chg_on_rtx);
	if (charger->chg_on_rtx) {
		gvotable_cast_long_vote(charger->dc_icl_votable,
					P9382A_RTX_VOTER,
					P9221_DC_ICL_RTX_UA, true);
		dev_info(&charger->client->dev, "set ICL to %dmA",
			 P9221_DC_ICL_RTX_UA / 1000);
	}
}

/* Handler for R5 and R7 chips */
static void p9221_irq_handler(struct p9221_charger_data *charger, u16 irq_src)
{
	int res;

	p9221_check_dc_reset(charger, irq_src);

	if (irq_src & charger->ints.stat_limit_mask)
		p9221_over_handle(charger, irq_src);

	/* Receive complete */
	if (irq_src & charger->ints.cc_data_rcvd_bit) {
		size_t rxlen = 0;

		res = charger->chip_get_cc_recv_size(charger, &rxlen);
		if (res) {
			dev_err(&charger->client->dev,
				"Failed to read len: %d\n", res);
			rxlen = 0;
		}
		if (rxlen) {
			res = charger->chip_get_data_buf(charger,
							 charger->rx_buf,
							 rxlen);
			if (res)
				dev_err(&charger->client->dev,
					"Failed to read len: %d\n", res);

			charger->rx_len = rxlen;
			charger->rx_done = true;
			charger->cc_data_lock.cc_rcv_at = get_boot_msec();
			set_renego_state(charger, P9XXX_AVAILABLE);
			sysfs_notify(&charger->dev->kobj, NULL, "rxdone");
		}
	}

	/* Send complete */
	if (irq_src & charger->ints.cc_send_busy_bit) {
		charger->tx_busy = false;
		charger->tx_done = true;
		charger->cc_data_lock.cc_use = true;
		charger->cc_data_lock.cc_rcv_at = 0;
		if (charger->cc_reset_pending) {
			charger->cc_data_lock.cc_use = false;
			charger->cc_reset_pending = false;
			wake_up_all(&charger->ccreset_wq);
		}
		cancel_delayed_work(&charger->tx_work);
		sysfs_notify(&charger->dev->kobj, NULL, "txbusy");
		sysfs_notify(&charger->dev->kobj, NULL, "txdone");
	}

	/* Proprietary packet */
	if (irq_src & charger->ints.pp_rcvd_bit) {
		p9221_handle_pp(charger);
	}

	/* CC Reset complete */
	if (irq_src & charger->ints.cc_reset_bit)
		p9221_abort_transfers(charger);

	if (irq_src & charger->ints.propmode_stat_bit) {
		u8 mode;

		res = charger->chip_get_sys_mode(charger, &mode);
		if (res == 0 && mode == P9XXX_SYS_OP_MODE_PROPRIETARY)
			charger->prop_mode_en = true;

		/* charger->prop_mode_en is reset on disconnect */
	}

	/* This only necessary for P9222 */
	if (irq_src & charger->ints.extended_mode_bit) {
		if (charger->check_rp == RP_NOTSET &&
		    charger->pdata->epp_rp_value != -1) {
			pm_stay_awake(charger->dev);
			charger->check_rp = RP_CHECKING;
			cancel_delayed_work_sync(&charger->chk_rp_work);
			schedule_delayed_work(&charger->chk_rp_work,
					      msecs_to_jiffies(P9XXX_CHK_RP_DELAY_MS));
		}
	}
}

#define IRQ_DEBOUNCE_TIME_MS		4
static irqreturn_t p9221_irq_thread(int irq, void *irq_data)
{
	struct p9221_charger_data *charger = irq_data;
	int ret;
	u16 irq_src = 0;
	ktime_t now = get_boot_msec();

	if ((now - charger->irq_at) < IRQ_DEBOUNCE_TIME_MS)
		return IRQ_HANDLED;

	charger->irq_at = now;

	pm_runtime_get_sync(charger->dev);
	if (!charger->resume_complete) {
		if (!charger->disable_irq) {
			charger->disable_irq = true;
			disable_irq_nosync(charger->pdata->irq_int);
		}
		pm_runtime_put_sync(charger->dev);
		return IRQ_HANDLED;
	}
	pm_runtime_put_sync(charger->dev);

	ret = p9221_reg_read_16(charger, P9221_INT_REG, &irq_src);
	if (ret) {
		dev_err(&charger->client->dev,
			"Failed to read INT reg: %d\n", ret);
		goto out;
	}

	/* TODO: interrupt storm with irq_src = when in rTX mode */
	if (!charger->ben_state) {
		dev_info(&charger->client->dev, "INT: %04x\n", irq_src);
		logbuffer_log(charger->log, "INT=%04x on:%d",
			      irq_src, charger->online);
	}

	if (!irq_src)
		goto out;

	ret = p9221_clear_interrupts(charger, irq_src);
	if (ret) {
		dev_err(&charger->client->dev,
			"Failed to clear INT reg: %d\n", ret);
		goto out;
	}

	/* todo interrupt handling for rx */
	if (charger->ben_state) {
		logbuffer_log(charger->rtx_log, "INT=%04x", irq_src);
		rtx_irq_handler(charger, irq_src);
		goto out;
	}

	if (irq_src & charger->ints.vrecton_bit) {
		dev_info(&charger->client->dev,
			"Received VRECTON, online=%d\n", charger->online);
		if (!charger->online) {
			charger->check_det = true;
			pm_stay_awake(charger->dev);

			if (!schedule_delayed_work(&charger->notifier_work,
				msecs_to_jiffies(P9221_NOTIFIER_DELAY_MS))) {
				pm_relax(charger->dev);
			}
		}
	}
	p9221_irq_handler(charger, irq_src);

out:
	return IRQ_HANDLED;
}

static irqreturn_t p9221_irq_det_thread(int irq, void *irq_data)
{
	struct p9221_charger_data *charger = irq_data;

	logbuffer_log(charger->log, "irq_det: online=%d ben=%d",
		      charger->online, charger->ben_state);

	/* If we are already online, just ignore the interrupt. */
	if (p9221_is_online(charger))
		return IRQ_HANDLED;

	if (charger->align != WLC_ALIGN_MOVE) {
		if (charger->align != WLC_ALIGN_CHECKING)
			schedule_work(&charger->uevent_work);
		charger->align = WLC_ALIGN_CHECKING;
		charger->align_count++;

		if (charger->align_count > WLC_ALIGN_IRQ_THRESHOLD) {
			schedule_work(&charger->uevent_work);
			charger->align = WLC_ALIGN_MOVE;
		}
		logbuffer_log(charger->log, "align: state: %s",
			      align_status_str[charger->align]);
	}

	del_timer(&charger->align_timer);

	/*
	 * This interrupt will wake the device if it's suspended,
	 * but it is not reliable enough to trigger the charging indicator.
	 * Give ourselves 2 seconds for the VRECTON interrupt to appear
	 * before we put up the charging indicator.
	 */
	mod_timer(&charger->vrect_timer,
		  jiffies + msecs_to_jiffies(P9221_VRECT_TIMEOUT_MS));
	pm_stay_awake(charger->dev);

	return IRQ_HANDLED;
}

static void p9xxx_chk_fod_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, chk_fod_work.work);

	if (!charger->online)
		return;

	p9221_write_fod(charger);
}

static void p9xxx_chk_rp_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, chk_rp_work.work);

	charger->chip_renegotiate_pwr(charger);
	pm_relax(charger->dev);
}


static void p9382_rtx_disable_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, rtx_disable_work);
	int tx_icl, ret = 0;

	/* Set error reason if THERMAL_DAEMON_VOTER want to disable rtx */
	tx_icl = gvotable_get_int_vote(charger->tx_icl_votable,
				       THERMAL_DAEMON_VOTER);
	if (tx_icl == 0) {
		charger->rtx_err = RTX_OVER_TEMP;
		logbuffer_log(charger->rtx_log,
			      "tdv vote %d to tx_icl",
			      tx_icl);
	}

	/* Disable rtx mode */
	ret = p9382_set_rtx(charger, false);
	if (ret)
		dev_err(&charger->client->dev,
			"unable to disable rtx: %d\n", ret);
}

/* send out a uevent notification and log iout/vout */
static void p9221_uevent_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, uevent_work);
	int ret;
	u32 vout, iout;

	kobject_uevent(&charger->dev->kobj, KOBJ_CHANGE);

	if (!charger->ben_state)
		return;

	ret = charger->chip_get_iout(charger, &iout);
	ret |= charger->chip_get_vout(charger, &vout);
	if (ret == 0) {
		logbuffer_log(charger->rtx_log,
			      "Vout=%umV, Iout=%umA, rx_lvl=%u",
			      vout, iout,
			      charger->rtx_csp);
	} else {
		logbuffer_log(charger->rtx_log, "failed to read rtx info.");
	}
}

static int p9221_parse_dt(struct device *dev,
			  struct p9221_charger_platform_data *pdata)
{
	int ret = 0;
	u32 data;
	struct device_node *node = dev->of_node;
	int vout_set_max_mv = P9221_VOUT_SET_MAX_MV;
	int vout_set_min_mv = P9221_VOUT_SET_MIN_MV;
	enum of_gpio_flags flags = 0;

	pdata->max_vout_mv = P9221_VOUT_SET_MAX_MV;

	if (of_device_is_compatible(node, "idt,p9412")) {
		dev_info(dev, "selecting p9412\n");
		pdata->chip_id = P9412_CHIP_ID;
		vout_set_min_mv = P9412_VOUT_SET_MIN_MV;
		vout_set_max_mv = P9412_VOUT_SET_MAX_MV;
	} else if (of_device_is_compatible(node, "idt,p9382")) {
		dev_info(dev, "selecting p9382\n");
		pdata->chip_id = P9382A_CHIP_ID;
	} else if (of_device_is_compatible(node, "idt,p9221")) {
		dev_info(dev, "selecting p9221\n");
		pdata->chip_id = P9221_CHIP_ID;
	} else if (of_device_is_compatible(node, "idt,p9222")) {
		dev_info(dev, "selecting p9222\n");
		pdata->chip_id = P9222_CHIP_ID;
	}

	/* QI_EN_L: enable/disable WLC chip */
	ret = of_get_named_gpio(node, "idt,gpio_qien", 0);
	pdata->qien_gpio = ret;
	if (ret < 0)
		dev_warn(dev, "unable to read idt,gpio_qien from dt: %d\n",
			 ret);
	else
		dev_info(dev, "enable gpio:%d", pdata->qien_gpio);

	/*
	 * QI_USB_VBUS_EN: control the priority of USB and WLC,
	 *                 set to high after boot
	 */
	ret = of_get_named_gpio_flags(node, "idt,gpio_qi_vbus_en", 0, &flags);
	pdata->qi_vbus_en = ret;
	if (ret < 0) {
		dev_warn(dev, "unable to read idt,gpio_qi_vbus_en from dt: %d\n",
			 ret);
	} else {
		pdata->qi_vbus_en_act_low = (flags & OF_GPIO_ACTIVE_LOW) != 0;
		dev_info(dev, "QI_USB_VBUS_EN gpio:%d(act_low=%d)",
			 pdata->qi_vbus_en, pdata->qi_vbus_en_act_low);
	}

	/* Enable/Disable WLC chip(for P9XXX_GPIO_VBUS_EN) */
	ret = of_get_named_gpio_flags(node, "idt,gpio_wlc_en", 0, &flags);
	pdata->wlc_en = ret;
	if (ret < 0) {
		dev_warn(dev, "unable to read idt,gpio_wlc_en from dt: %d\n",
			 ret);
	} else {
		pdata->wlc_en_act_low = (flags & OF_GPIO_ACTIVE_LOW) != 0;
		dev_info(dev, "WLC enable/disable pin:%d", pdata->wlc_en);
	}

	/* WLC_BPP_EPP_SLCT */
	ret = of_get_named_gpio(node, "idt,gpio_slct", 0);
	pdata->slct_gpio = ret;
	if (ret < 0) {
		dev_warn(dev, "unable to read idt,gpio_slct from dt: %d\n",
			 ret);
	} else {
		ret = of_property_read_u32(node, "idt,gpio_slct_value", &data);
		if (ret == 0)
			pdata->slct_value = (data != 0);

		dev_info(dev, "WLC_BPP_EPP_SLCT gpio:%d value=%d",
					pdata->slct_gpio, pdata->slct_value);
	}

	/* RTx: idt,gpio_ben / idt,gpio_switch / idt,gpio_boost */
	ret = of_property_read_u32(node, "idt,has_rtx", &data);
	if (ret == 0)
		pdata->has_rtx = !!data;
	else
		pdata->has_rtx =
		    ((pdata->chip_id == P9412_CHIP_ID) ||
		     (pdata->chip_id == P9382A_CHIP_ID));
	dev_info(dev, "has_rtx:%d\n", pdata->has_rtx);

	/* boost enable, power WLC IC from device */
	ret = of_get_named_gpio(node, "idt,gpio_ben", 0);
	if (ret == -EPROBE_DEFER)
		return ret;
	pdata->ben_gpio = ret;
	if (ret >= 0)
		dev_info(dev, "ben gpio:%d\n", pdata->ben_gpio);

	ret = of_get_named_gpio(node, "idt,gpio_switch", 0);
	if (ret == -EPROBE_DEFER)
		return ret;
	pdata->switch_gpio = ret;
	if (ret >= 0)
		dev_info(dev, "switch gpio:%d\n", pdata->switch_gpio);

	/* boost gpio sets rtx at charging voltage level */
	ret = of_get_named_gpio(node, "idt,gpio_boost", 0);
	if (ret == -EPROBE_DEFER)
		return ret;
	pdata->boost_gpio = ret;
	if (ret >= 0)
		dev_info(dev, "boost gpio:%d\n", pdata->boost_gpio);

	/* configure boost to 7V through wlc chip */
	pdata->apbst_en = of_property_read_bool(node, "idt,apbst_en");
	/* support HW detect OCP in ping phase */
	pdata->hw_ocp_det = of_property_read_bool(node, "idt,hw_ocp_det");

	ret = of_get_named_gpio(node, "idt,gpio_extben", 0);
	if (ret == -EPROBE_DEFER)
		return ret;
	pdata->ext_ben_gpio = ret;
	if (ret >= 0) {
		ret = gpio_request(pdata->ext_ben_gpio, "wc_ref");
		dev_info(dev, "ext ben gpio:%d, ret=%d\n", pdata->ext_ben_gpio, ret);
	}

	/* DC-PPS */
	ret = of_get_named_gpio(node, "idt,gpio_dc_switch", 0);
	if (ret == -EPROBE_DEFER)
		return ret;
	pdata->dc_switch_gpio = ret;
	if (ret >= 0)
		dev_info(dev, "dc_switch gpio:%d\n", pdata->dc_switch_gpio);

	ret = of_property_read_u32(node, "idt,has_wlc_dc", &data);
	if (ret == 0)
		pdata->has_wlc_dc = !!data;
	else
		pdata->has_wlc_dc = pdata->chip_id == P9412_CHIP_ID;
	dev_info(dev, "has_wlc_dc:%d\n", pdata->has_wlc_dc);

	/* Main IRQ */
	ret = of_get_named_gpio(node, "idt,irq_gpio", 0);
	if (ret < 0) {
		dev_err(dev, "unable to read idt,irq_gpio from dt: %d\n", ret);
		return ret;
	}
	pdata->irq_gpio = ret;
	pdata->irq_int = gpio_to_irq(pdata->irq_gpio);
	dev_info(dev, "gpio:%d, gpio_irq:%d\n", pdata->irq_gpio,
		 pdata->irq_int);

	/* Optional Detect IRQ */
	ret = of_get_named_gpio(node, "idt,irq_det_gpio", 0);
	pdata->irq_det_gpio = ret;
	if (ret < 0) {
		dev_warn(dev, "unable to read idt,irq_det_gpio from dt: %d\n",
			 ret);
	} else {
		pdata->irq_det_int = gpio_to_irq(pdata->irq_det_gpio);
		dev_info(dev, "det gpio:%d, det gpio_irq:%d\n",
			 pdata->irq_det_gpio, pdata->irq_det_int);
	}

	/* Optional VOUT max */
	pdata->max_vout_mv = P9221_MAX_VOUT_SET_MV_DEFAULT;
	ret = of_property_read_u32(node, "idt,max_vout_mv", &data);
	if (ret == 0) {
		if (data < vout_set_min_mv || data > vout_set_max_mv)
			dev_err(dev, "max_vout_mv out of range %d\n", data);
		else
			pdata->max_vout_mv = data;
	}

	/* Optional FOD data */
	pdata->fod_num =
	    of_property_count_elems_of_size(node, "fod", sizeof(u8));
	if (pdata->fod_num <= 0) {
		dev_err(dev, "No dt fod provided (%d)\n", pdata->fod_num);
		pdata->fod_num = 0;
	} else {
		if (pdata->fod_num > P9221R5_NUM_FOD) {
			dev_err(dev,
			    "Incorrect num of FOD %d, using first %d\n",
			    pdata->fod_num, P9221R5_NUM_FOD);
			pdata->fod_num = P9221R5_NUM_FOD;
		}
		ret = of_property_read_u8_array(node, "fod", pdata->fod,
						pdata->fod_num);
		if (ret == 0) {
			char buf[P9221R5_NUM_FOD * 3 + 1];

			p9221_hex_str(pdata->fod, pdata->fod_num, buf,
				      pdata->fod_num * 3 + 1, false);
			dev_info(dev, "dt fod: %s (%d)\n", buf, pdata->fod_num);
		}
	}

	pdata->fod_epp_num =
	    of_property_count_elems_of_size(node, "fod_epp", sizeof(u8));
	if (pdata->fod_epp_num <= 0) {
		dev_err(dev, "No dt fod epp provided (%d)\n",
			pdata->fod_epp_num);
		pdata->fod_epp_num = 0;
	} else {
		if (pdata->fod_epp_num > P9221R5_NUM_FOD) {
			dev_err(dev,
			    "Incorrect num of EPP FOD %d, using first %d\n",
			    pdata->fod_epp_num, P9221R5_NUM_FOD);
			pdata->fod_epp_num = P9221R5_NUM_FOD;
		}
		ret = of_property_read_u8_array(node, "fod_epp", pdata->fod_epp,
						pdata->fod_epp_num);
		if (ret == 0) {
			char buf[P9221R5_NUM_FOD * 3 + 1];

			p9221_hex_str(pdata->fod_epp, pdata->fod_epp_num, buf,
				      pdata->fod_epp_num * 3 + 1, false);
			dev_info(dev, "dt fod_epp: %s (%d)\n", buf,
				 pdata->fod_epp_num);
		}
	}


	pdata->fod_epp_comp_num =
	    of_property_count_elems_of_size(node, "fod_epp_comp", sizeof(u8));
	if (pdata->fod_epp_comp_num <= 0) {
		dev_err(dev, "No dt fod epp comp provided (%d)\n",
			pdata->fod_epp_comp_num);
		pdata->fod_epp_comp_num = 0;
	} else {
		if (pdata->fod_epp_comp_num > P9221R5_NUM_FOD) {
			dev_err(dev, "Incorrect num of EPP COMP FOD %d, using first %d\n",
				pdata->fod_epp_comp_num, P9221R5_NUM_FOD);
			pdata->fod_epp_comp_num = P9221R5_NUM_FOD;
		}
		ret = of_property_read_u8_array(node, "fod_epp_comp", pdata->fod_epp_comp,
						pdata->fod_epp_comp_num);
		if (ret == 0) {
			char buf[P9221R5_NUM_FOD * 3 + 1];

			p9221_hex_str(pdata->fod_epp_comp, pdata->fod_epp_comp_num, buf,
				      pdata->fod_epp_comp_num * 3 + 1, false);
			dev_info(dev, "dt fod_epp_comp: %s (%d)\n", buf,
				 pdata->fod_epp_comp_num);
		}
	}

	pdata->fod_hpp_num =
	    of_property_count_elems_of_size(node, "fod_hpp", sizeof(u8));
	if (pdata->fod_hpp_num <= 0) {
		pdata->fod_hpp_num = 0;
	} else {
		if (pdata->fod_hpp_num > P9221R5_NUM_FOD) {
			dev_err(dev, "Incorrect num of HPP FOD %d, using first %d\n",
				pdata->fod_hpp_num, P9221R5_NUM_FOD);
			pdata->fod_hpp_num = P9221R5_NUM_FOD;
		}
		ret = of_property_read_u8_array(node, "fod_hpp", pdata->fod_hpp,
						pdata->fod_hpp_num);
		if (ret == 0) {
			char buf[P9221R5_NUM_FOD * 3 + 1];

			p9221_hex_str(pdata->fod_hpp, pdata->fod_hpp_num, buf,
				      pdata->fod_hpp_num * 3 + 1, false);
			dev_info(dev, "dt fod_hpp: %s (%d)\n", buf,
				 pdata->fod_hpp_num);
		}
	}

	pdata->fod_hpp_hv_num =
	    of_property_count_elems_of_size(node, "fod_hpp_hv", sizeof(u8));
	if (pdata->fod_hpp_hv_num <= 0) {
		pdata->fod_hpp_hv_num = 0;
	} else {
		if (pdata->fod_hpp_hv_num > P9221R5_NUM_FOD) {
			dev_err(dev, "Incorrect num of HPP HV FOD %d, using first %d\n",
				pdata->fod_hpp_hv_num, P9221R5_NUM_FOD);
			pdata->fod_hpp_hv_num = P9221R5_NUM_FOD;
		}
		ret = of_property_read_u8_array(node, "fod_hpp_hv", pdata->fod_hpp_hv,
						pdata->fod_hpp_hv_num);
		if (ret == 0) {
			char buf[P9221R5_NUM_FOD * 3 + 1];

			p9221_hex_str(pdata->fod_hpp_hv, pdata->fod_hpp_hv_num, buf,
				      pdata->fod_hpp_hv_num * 3 + 1, false);
			dev_info(dev, "dt fod_hpp_hv: %s (%d)\n", buf,
				 pdata->fod_hpp_hv_num);
		}
	}

	ret = of_property_read_bool(node, "google,fod_fsw_base");
	if (ret)
		pdata->fod_fsw = true;

	ret = of_property_read_u32(node, "google,fod_fsw_high_thres", &data);
	if (ret < 0) {
		pdata->fod_fsw_high = -1;
	} else {
		pdata->fod_fsw_high = data;
		dev_info(dev, "dt fod_fsw_high_thres:%d\n", pdata->fod_fsw_high);
	}

	ret = of_property_read_u32(node, "google,fod_fsw_low_thres", &data);
	if (ret < 0) {
		pdata->fod_fsw_low = -1;
	} else {
		pdata->fod_fsw_low = data;
		dev_info(dev, "dt fod_fsw_low_thres:%d\n", pdata->fod_fsw_low);
	}

	ret = of_property_read_u32(node, "google,q_value", &data);
	if (ret < 0) {
		pdata->q_value = -1;
	} else {
		pdata->q_value = data;
		dev_info(dev, "dt q_value:%d\n", pdata->q_value);
	}

	ret = of_property_read_u32(node, "google,tx4191_q", &data);
	if (ret < 0) {
		pdata->tx_4191q = -1;
	} else {
		pdata->tx_4191q = data;
		dev_info(dev, "dt tx4191_q:%d\n", pdata->tx_4191q);
	}

	ret = of_property_read_u32(node, "google,epp_rp_value", &data);
	if (ret < 0) {
		pdata->epp_rp_value = -1;
	} else {
		pdata->epp_rp_value = data;
		dev_info(dev, "dt epp_rp_value: %d\n", pdata->epp_rp_value);
	}

	ret = of_property_read_u32(node, "google,epp_rp_low_value", &data);
	if (ret < 0) {
		pdata->epp_rp_low_value = -1;
	} else {
		pdata->epp_rp_low_value = data;
		dev_info(dev, "dt epp_rp_low_value: %d\n", pdata->epp_rp_low_value);
	}

	pdata->epp_vout_mv = P9221_MAX_VOUT_SET_MV_DEFAULT;
	ret = of_property_read_u32(node, "google,epp_vout_mv", &data);
	if (ret == 0) {
		if (data < vout_set_min_mv || data > vout_set_max_mv)
			dev_err(dev, "epp_vout_mv out of range %d\n", data);
		else
			pdata->epp_vout_mv = data;
	}

	ret = of_property_read_u32(node, "google,needs_dcin_reset", &data);
	if (ret < 0) {
		pdata->needs_dcin_reset = -1;
	} else {
		pdata->needs_dcin_reset = data;
		dev_info(dev, "dt needs_dcin_reset: %d\n",
			 pdata->needs_dcin_reset);
	}

	pdata->nb_alignment_freq =
			of_property_count_elems_of_size(node,
							"google,alignment_frequencies",
							sizeof(u32));
	dev_info(dev, "dt google,alignment_frequencies size = %d\n",
		 pdata->nb_alignment_freq);

	if (pdata->nb_alignment_freq > 0) {
		pdata->alignment_freq =
				devm_kmalloc_array(dev,
						   pdata->nb_alignment_freq,
						   sizeof(u32),
						   GFP_KERNEL);
		if (!pdata->alignment_freq) {
			dev_warn(dev,
				 "dt google,alignment_frequencies array not created");
		} else {
			ret = of_property_read_u32_array(node,
							 "google,alignment_frequencies",
							 pdata->alignment_freq,
							 pdata->nb_alignment_freq);
			if (ret) {
				dev_warn(dev,
					 "failed to read google,alignment_frequencies: %d\n",
					 ret);
				devm_kfree(dev, pdata->alignment_freq);
			}
		}
	}

	ret = of_property_read_u32(node, "google,alignment_scalar", &data);
	if (ret < 0)
		pdata->alignment_scalar = WLC_ALIGN_DEFAULT_SCALAR;
	else {
		pdata->alignment_scalar = data;
		if (pdata->alignment_scalar != WLC_ALIGN_DEFAULT_SCALAR)
			dev_info(dev, "google,alignment_scalar updated to: %d\n",
				 pdata->alignment_scalar);
	}

	ret = of_property_read_u32(node, "google,alignment_hysteresis", &data);
	if (ret < 0)
		pdata->alignment_hysteresis = WLC_ALIGN_DEFAULT_HYSTERESIS;
	else
		pdata->alignment_hysteresis = data;

	dev_info(dev, "google,alignment_hysteresis set to: %d\n",
				 pdata->alignment_hysteresis);

	ret = of_property_read_bool(node, "idt,ramp-disable");
	if (ret)
		pdata->icl_ramp_delay_ms = -1;

	ret = of_property_read_u32(node, "google,alignment_scalar_low_current",
				   &data);
	if (ret < 0)
		pdata->alignment_scalar_low_current =
			WLC_ALIGN_DEFAULT_SCALAR_LOW_CURRENT;
	else
		pdata->alignment_scalar_low_current = data;

	dev_info(dev, "google,alignment_scalar_low_current set to: %d\n",
		 pdata->alignment_scalar_low_current);

	ret = of_property_read_u32(node, "google,alignment_scalar_high_current",
				   &data);
	if (ret < 0)
		pdata->alignment_scalar_high_current =
			  WLC_ALIGN_DEFAULT_SCALAR_HIGH_CURRENT;
	else
		pdata->alignment_scalar_high_current = data;

	dev_info(dev, "google,alignment_scalar_high_current set to: %d\n",
		 pdata->alignment_scalar_high_current);

	ret = of_property_read_u32(node, "google,alignment_offset_low_current",
				   &data);
	if (ret < 0)
		pdata->alignment_offset_low_current =
			WLC_ALIGN_DEFAULT_OFFSET_LOW_CURRENT;
	else
		pdata->alignment_offset_low_current = data;

	dev_info(dev, "google,alignment_offset_low_current set to: %d\n",
		 pdata->alignment_offset_low_current);

	ret = of_property_read_u32(node, "google,alignment_offset_high_current",
				   &data);
	if (ret < 0)
		pdata->alignment_offset_high_current =
			WLC_ALIGN_DEFAULT_OFFSET_HIGH_CURRENT;
	else
		pdata->alignment_offset_high_current = data;

	dev_info(dev, "google,alignment_offset_high_current set to: %d\n",
		 pdata->alignment_offset_high_current);

	ret = of_property_read_u32(node, "google,alignment_current_threshold",
				   &data);
	if (ret < 0)
		pdata->alignment_current_threshold = WLC_ALIGN_CURRENT_THRESHOLD;
	else
		pdata->alignment_current_threshold = data;

	dev_info(dev, "google,alignment_current_threshold set to: %d\n",
		 pdata->alignment_current_threshold);

	ret = of_property_read_u32(node, "google,power_mitigate_threshold",
				   &data);
	if (ret < 0)
		pdata->power_mitigate_threshold = 0;
	else
		pdata->power_mitigate_threshold = data;

	ret = of_property_read_bool(node, "google,feat-no-compat");
	if (!ret)
		pdata->feat_compat_mode = true; /* default is compat*/

	ret = of_property_read_bool(node, "google,has-sw-ramp");
	if (ret)
		pdata->has_sw_ramp = true;

	ret = of_property_read_u8(node,"idt,tx_id_phone_type",
				  &pdata->phone_type);
	if (ret < 0)
		pdata->phone_type = 0;

	ret = of_property_read_u32(node, "google,epp_dcicl_default_ma", &data);
	if (ret < 0)
		pdata->epp_icl = 0;
	else
		pdata->epp_icl = data;

	/* Calibrate light load */
	pdata->light_load = of_property_read_bool(node, "google,light_load");

	return 0;
}

static enum power_supply_property p9221_props[] = {
	POWER_SUPPLY_PROP_PRESENT,
	POWER_SUPPLY_PROP_ONLINE,
	POWER_SUPPLY_PROP_CURRENT_NOW,
	POWER_SUPPLY_PROP_CURRENT_MAX,
	POWER_SUPPLY_PROP_VOLTAGE_NOW,
	POWER_SUPPLY_PROP_VOLTAGE_MAX,
	POWER_SUPPLY_PROP_VOLTAGE_MIN,
	POWER_SUPPLY_PROP_TEMP,
#ifdef CONFIG_QC_COMPAT
	POWER_SUPPLY_PROP_AICL_DELAY,
	POWER_SUPPLY_PROP_AICL_ICL,
#endif
	POWER_SUPPLY_PROP_SERIAL_NUMBER,
	POWER_SUPPLY_PROP_CAPACITY,
};

static const struct power_supply_desc p9221_psy_desc = {
	.name = "wireless",
	.type = POWER_SUPPLY_TYPE_WIRELESS,
	.properties = p9221_props,
	.num_properties = ARRAY_SIZE(p9221_props),
	.get_property = p9221_get_property,
	.set_property = p9221_set_property,
	.property_is_writeable = p9221_prop_is_writeable,
	.no_thermal = true,
};

static int p9382a_tx_icl_vote_callback(struct gvotable_election *el,
				       const char *reason, void *vote)
{
	struct p9221_charger_data *charger = gvotable_get_data(el);
	int icl_ua = GVOTABLE_PTR_TO_INT(vote);
	int ret = 0;

	if (!charger->ben_state)
		return 0;

	if (icl_ua == 0) {
		schedule_work(&charger->rtx_disable_work);
	} else {
		ret = charger->chip_set_tx_ilim(charger,
						P9221_UA_TO_MA(icl_ua));
		if (ret == 0)
			logbuffer_log(charger->rtx_log, "set TX_ICL to %dmA",
				      icl_ua);
		else
			dev_err(&charger->client->dev,
				"Couldn't set Tx current limit rc=%d\n", ret);
	}

	return 0;
}

/* called from */
int p9221_wlc_disable(struct p9221_charger_data *charger, int disable, u8 reason)
{
	int ret = 0;

	if ((disable && charger->online) || charger->send_eop) {
		int rc;

		ret = charger->chip_send_eop(charger, reason);

		rc = charger->reg_write_8(charger, P9412_CMFET_L_REG, P9412_CMFET_DISABLE_ALL);
		rc |= charger->reg_write_8(charger, P9412_HIVOUT_CMFET_REG, P9412_CMFET_DISABLE_ALL);

		pr_info("Disabled Rx communication channel(CMFET): 0xF4 & 0x11B (%d)\n", rc);
		charger->send_eop = false;
	}

	/*
	 * could also change ->qien_gpio (e.g pull low when disable == 0)
	 * and/or toggle inhibit via ->qi_vbus_en.
	 * NOTE: using ->qien_gpio to disable the IC while VOUT sis present
	 * might (is) not supported.
	 */

	pr_debug("%s: disable=%d, ept_reason=%d ret=%d\n", __func__,
		 disable, disable ? reason : -1, ret);

	if (charger->last_disable != disable) {
		pr_info("%s[%d]: disable=%d, ept_reason=%d ret=%d\n", __func__,
			charger->online, disable, reason, ret);
		logbuffer_log(charger->log, "Set wlc_disable=%d", disable);
	}

	charger->last_disable = disable;
	return ret;
}

static int p9221_wlc_disable_callback(struct gvotable_election *el,
				      const char *reason, void *vote)
{
	struct p9221_charger_data *charger = gvotable_get_data(el);
	int disable = GVOTABLE_PTR_TO_INT(vote);
	u8 val = P9221_EOP_UNKNOWN;

	if (charger->pdata->wlc_en == charger->pdata->qien_gpio) {
		int value;
		value = (!disable) ^ charger->pdata->wlc_en_act_low;
		gpio_direction_output(charger->pdata->wlc_en, value);
		return 0;
	}

	charger->send_eop = gvotable_get_int_vote(charger->dc_icl_votable,
						  THERMAL_DAEMON_VOTER) == 0;
	if (!gvotable_get_int_vote(el, P9221_WLC_VOTER) && !charger->send_eop)
		val = P9221_EOP_RESTART_POWER; /* auto restart */

	p9221_wlc_disable(charger, disable, val);

	return 0;
}

/*
 *  If able to read the chip_id register then we know we are online
 *
 *  Returns true when online.
 */
static bool p9221_check_online(struct p9221_charger_data *charger)
{
	int ret;
	u16 chip_id;

	/* Test to see if the charger is online */
	ret = p9221_reg_read_16(charger, P9221_CHIP_ID_REG, &chip_id);
	if (ret == 0) {
		dev_info(charger->dev, "Charger online id:%04x\n", chip_id);
		return true;
	}

	return false;
}

static void p9221_fg_work(struct work_struct *work)
{
	struct p9221_charger_data *charger = container_of(work,
			struct p9221_charger_data, fg_work.work);
	union power_supply_propval prop = { };
	int err;

	if (!charger->fg_psy) {
		static struct power_supply *psy[2];

		err = power_supply_get_by_phandle_array(charger->dev->of_node,
							"idt,fuel-gauge",
							psy, ARRAY_SIZE(psy));
		if (err < 0 || IS_ERR_OR_NULL(psy[0])) {
			schedule_delayed_work(&charger->fg_work, msecs_to_jiffies(1000));
			pr_info("%s: wait for fg err=%d\n", __func__, err);
			return;
		}

		dev_info(charger->dev, "Reading CSP from %s\n",
			 psy[0]->desc && psy[0]->desc->name ? psy[0]->desc->name : "<>");
		charger->fg_psy = psy[0];
	}

	/* triggered from notifier_cb */
	err = power_supply_get_property(charger->fg_psy, POWER_SUPPLY_PROP_CAPACITY,
					&prop);
	if (err == 0)
		p9221_set_capacity(charger, prop.intval);
}

static int p9221_charger_probe(struct i2c_client *client,
				const struct i2c_device_id *id)
{
	struct device_node *dn, *of_node = client->dev.of_node;
	struct p9221_charger_data *charger;
	struct p9221_charger_platform_data *pdata = client->dev.platform_data;
	struct power_supply_config psy_cfg = {};
	bool online;
	int ret;

	ret = i2c_check_functionality(client->adapter,
				      I2C_FUNC_SMBUS_BYTE_DATA |
				      I2C_FUNC_SMBUS_WORD_DATA |
				      I2C_FUNC_SMBUS_I2C_BLOCK);
	if (!ret) {
		ret = i2c_get_functionality(client->adapter);
		dev_err(&client->dev, "I2C adapter not compatible %x\n", ret);
		return -ENOSYS;
	}

	if (of_node) {
		pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
		if (!pdata) {
			dev_err(&client->dev, "Failed to allocate pdata\n");
			return -ENOMEM;
		}

		ret = p9221_parse_dt(&client->dev, pdata);
		if (ret) {
			dev_err(&client->dev, "Failed to parse dt\n");
			return ret;
		}

	}

	charger = devm_kzalloc(&client->dev, sizeof(*charger), GFP_KERNEL);
	if (charger == NULL) {
		dev_err(&client->dev, "Failed to allocate charger\n");
		return -ENOMEM;
	}
	i2c_set_clientdata(client, charger);
	charger->dev = &client->dev;
	charger->client = client;
	charger->pdata = pdata;
	charger->resume_complete = true;
	charger->align = WLC_ALIGN_ERROR;
	charger->align_count = 0;
	charger->is_mfg_google = false;
	charger->fw_rev = 0;
	charger->p9412_gpio_ctl = false;
	charger->chip_id = charger->pdata->chip_id;
	charger->rtx_wakelock = false;
	charger->last_disable = -1;
	charger->irq_at = 0;
	charger->ll_bpp_cep = -EINVAL;
	charger->check_rp = RP_NOTSET;
	mutex_init(&charger->io_lock);
	mutex_init(&charger->cmd_lock);
	mutex_init(&charger->stats_lock);
	mutex_init(&charger->chg_features.feat_lock);
	mutex_init(&charger->rtx_lock);
	mutex_init(&charger->auth_lock);
	mutex_init(&charger->renego_lock);
	timer_setup(&charger->vrect_timer, p9221_vrect_timer_handler, 0);
	timer_setup(&charger->align_timer, p9221_align_timer_handler, 0);
	INIT_DELAYED_WORK(&charger->dcin_work, p9221_dcin_work);
	INIT_DELAYED_WORK(&charger->charge_stats_work, p9221_charge_stats_work);
	INIT_DELAYED_WORK(&charger->tx_work, p9221_tx_work);
	INIT_DELAYED_WORK(&charger->txid_work, p9382_txid_work);
	INIT_DELAYED_WORK(&charger->icl_ramp_work, p9221_icl_ramp_work);
	INIT_DELAYED_WORK(&charger->align_work, p9221_align_work);
	INIT_DELAYED_WORK(&charger->dcin_pon_work, p9221_dcin_pon_work);
	INIT_DELAYED_WORK(&charger->rtx_work, p9382_rtx_work);
	INIT_DELAYED_WORK(&charger->auth_dc_icl_work, p9221_auth_dc_icl_work);
	INIT_DELAYED_WORK(&charger->fg_work, p9221_fg_work);
	INIT_DELAYED_WORK(&charger->chk_rp_work, p9xxx_chk_rp_work);
	INIT_DELAYED_WORK(&charger->chk_rtx_ocp_work, p9412_chk_rtx_ocp_work);
	INIT_DELAYED_WORK(&charger->chk_fod_work, p9xxx_chk_fod_work);
	INIT_WORK(&charger->uevent_work, p9221_uevent_work);
	INIT_WORK(&charger->rtx_disable_work, p9382_rtx_disable_work);
	INIT_WORK(&charger->rtx_reset_work, p9xxx_rtx_reset_work);
	INIT_DELAYED_WORK(&charger->power_mitigation_work,
			  p9221_power_mitigation_work);
	alarm_init(&charger->icl_ramp_alarm, ALARM_BOOTTIME,
		   p9221_icl_ramp_alarm_cb);
	alarm_init(&charger->auth_dc_icl_alarm, ALARM_BOOTTIME,
		   p9221_auth_dc_icl_alarm_cb);

	init_waitqueue_head(&charger->ccreset_wq);

	charger->align_ws = wakeup_source_register(NULL, "p9221_align");

	/* setup function pointers for platform */
	/* first from *_charger.c -> *_chip.c */
	charger->reg_read_n = p9221_reg_read_n;
	charger->reg_read_8 = p9221_reg_read_8;
	charger->reg_read_16 = p9221_reg_read_16;
	charger->reg_write_n = p9221_reg_write_n;
	charger->reg_write_8 = p9221_reg_write_8;
	charger->reg_write_16 = p9221_reg_write_16;
	/* then from *_chip.c -> *_charger.c */
	p9221_chip_init_params(charger, charger->pdata->chip_id);
	p9221_chip_init_interrupt_bits(charger, charger->pdata->chip_id);
	ret = p9221_chip_init_funcs(charger, charger->pdata->chip_id);
	if (ret) {
		dev_err(&client->dev,
			"Failed to initialize chip specific information\n");
		return ret;
	}

	p9221_charge_stats_init(&charger->chg_data);

	/* Default enable */
	charger->enabled = true;
	if (charger->pdata->qien_gpio >= 0)
		gpio_direction_output(charger->pdata->qien_gpio, 0);

	if (charger->pdata->qi_vbus_en >= 0)
		gpio_direction_output(charger->pdata->qi_vbus_en,
				      !charger->pdata->qi_vbus_en_act_low);

	if (charger->pdata->slct_gpio >= 0)
		gpio_direction_output(charger->pdata->slct_gpio,
				      charger->pdata->slct_value);

	if (charger->pdata->ben_gpio >= 0)
		gpio_direction_output(charger->pdata->ben_gpio, 0);

	if (charger->pdata->switch_gpio >= 0)
		gpio_direction_output(charger->pdata->switch_gpio, 0);

	if (charger->pdata->ext_ben_gpio >= 0)
		gpio_direction_output(charger->pdata->ext_ben_gpio, 0);

	if (charger->pdata->dc_switch_gpio >= 0)
		gpio_direction_output(charger->pdata->dc_switch_gpio, 0);


	/* Default to R5+ */
	charger->cust_id = 5;

	psy_cfg.drv_data = charger;
	psy_cfg.of_node = charger->dev->of_node;
	charger->wc_psy = devm_power_supply_register(charger->dev,
						     &p9221_psy_desc,
						     &psy_cfg);
	if (IS_ERR(charger->wc_psy)) {
		dev_err(&client->dev, "Fail to register supply: %d\n", ret);
		return PTR_ERR(charger->wc_psy);
	}

	/*
	 * Create the WLC_DISABLE votable, use for send EPT
	 * NOTE: pulling QI_EN_L might not be OK, verify this with EE
	 */
	charger->wlc_disable_votable =
		gvotable_create_bool_election(NULL, p9221_wlc_disable_callback,
					      charger);
	if (IS_ERR(charger->wlc_disable_votable)) {
		ret = PTR_ERR(charger->wlc_disable_votable);
		dev_err(&client->dev,
			"Couldn't create WLC_DISABLE rc=%d\n", ret);
		charger->wlc_disable_votable = NULL;
	} else {
		gvotable_set_vote2str(charger->wlc_disable_votable,
				      gvotable_v2s_int);
		gvotable_election_set_name(charger->wlc_disable_votable,
					   "WLC_DISABLE");
	}

	/*
	 * Create the RTX_ICL votable, we use this to limit the current that
	 * is taken for RTx mode
	 */
	if (charger->pdata->has_rtx) {
		charger->tx_icl_votable =
			gvotable_create_int_election(
				NULL, gvotable_comparator_int_min,
				p9382a_tx_icl_vote_callback, charger);
		if (IS_ERR(charger->tx_icl_votable)) {
			ret = PTR_ERR(charger->tx_icl_votable);
			dev_err(&client->dev,
				"Couldn't create TX_ICL rc=%d\n", ret);
			charger->tx_icl_votable = NULL;
		} else {
			gvotable_set_vote2str(charger->tx_icl_votable,
					      gvotable_v2s_int);
			gvotable_election_set_name(charger->tx_icl_votable,
						   "TX_ICL");
			/* vote default TX_ICL for rtx mode */
			gvotable_cast_long_vote(
				charger->tx_icl_votable, P9382A_RTX_VOTER,
				P9221_MA_TO_UA(P9382A_RTX_ICL_MAX_MA), true);
		}
	}

	/*
	 * Find the DC_ICL votable, we use this to limit the current that
	 * is taken from the wireless charger.
	 */
	charger->dc_icl_votable = gvotable_election_get_handle("DC_ICL");
	if (!charger->dc_icl_votable)
		dev_warn(&charger->client->dev, "Could not find DC_ICL votable\n");

	/*
	 * Find the DC_SUSPEND, we use this to disable DCIN before
	 * enter RTx mode
	 */
	charger->dc_suspend_votable =
		gvotable_election_get_handle("DC_SUSPEND");
	if (!charger->dc_suspend_votable)
		dev_warn(&charger->client->dev, "Could not find DC_SUSPEND votable\n");

	charger->chg_mode_votable =
		gvotable_election_get_handle(GBMS_MODE_VOTABLE);
	if (!charger->chg_mode_votable)
		dev_warn(&charger->client->dev, "Could not find %s votable\n", GBMS_MODE_VOTABLE);

	/* Ramping on BPP is optional */
	if (charger->pdata->icl_ramp_delay_ms != -1) {
		charger->icl_ramp_ua = P9221_DC_ICL_BPP_RAMP_DEFAULT_UA;
		charger->pdata->icl_ramp_delay_ms =
					P9221_DC_ICL_BPP_RAMP_DELAY_DEFAULT_MS;
	}

	charger->dc_icl_bpp = 0;
	charger->dc_icl_epp = 0;
	charger->dc_icl_epp_neg = charger->pdata->epp_icl > 0 ? charger->pdata->epp_icl : P9221_DC_ICL_EPP_UA;
	charger->aicl_icl_ua = 0;
	charger->aicl_delay_ms = 0;

	crc8_populate_msb(p9221_crc8_table, P9221_CRC8_POLYNOMIAL);

	online = p9221_check_online(charger);
	dev_info(&client->dev, "online = %d CHIP_ID = 0x%x\n", online,
		 charger->chip_id);

	if (online) {
		/* set charger->online=true, will ignore first VRECTON IRQ */
		p9221_set_online(charger);
	} else {
		/* disconnected, (likely err!=0) vote for BPP */
		p9221_vote_defaults(charger);
	}

	ret = devm_request_threaded_irq(
		&client->dev, charger->pdata->irq_int, NULL,
		p9221_irq_thread, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
		"p9221-irq", charger);
	if (ret) {
		dev_err(&client->dev, "Failed to request IRQ\n");
		return ret;
	}
	device_init_wakeup(charger->dev, true);

	/*
	 * We will receive a VRECTON after enabling IRQ if the device is
	 * if the device is already in-field when the driver is probed.
	 */
	enable_irq_wake(charger->pdata->irq_int);

	if (gpio_is_valid(charger->pdata->irq_det_gpio)) {
		ret = devm_request_threaded_irq(
			&client->dev, charger->pdata->irq_det_int, NULL,
			p9221_irq_det_thread,
			IRQF_TRIGGER_RISING | IRQF_ONESHOT, "p9221-irq-det",
			charger);
		if (ret) {
			dev_err(&client->dev, "Failed to request IRQ_DET\n");
			return ret;
		}

		ret = devm_gpio_request_one(&client->dev,
					    charger->pdata->irq_det_gpio,
					    GPIOF_DIR_IN, "p9221-det-gpio");
		if (ret) {
			dev_err(&client->dev, "Failed to request GPIO_DET\n");
			return ret;
		}
		enable_irq_wake(charger->pdata->irq_det_int);
	}

	charger->last_capacity = -1;
	charger->count = 1;
	bin_attr_rxdata.size = charger->rx_buf_size;
	bin_attr_txdata.size = charger->tx_buf_size;
	ret = sysfs_create_group(&charger->dev->kobj, &p9221_attr_group);
	if (ret) {
		dev_info(&client->dev, "sysfs_create_group failed\n");
	}
	if (charger->pdata->has_rtx) {
		ret = sysfs_create_group(&charger->dev->kobj, &rtx_attr_group);
		if (ret)
			dev_info(&client->dev, "rtx sysfs_create_group failed\n");
	}

	charger->debug_entry = debugfs_create_dir("p9221_charger", 0);
	if (IS_ERR_OR_NULL(charger->debug_entry)) {
		charger->debug_entry = NULL;
		dev_err(&client->dev, "Failed to create debug_entry\n");
	} else {
		debugfs_create_bool("no_fod", 0644, charger->debug_entry, &charger->no_fod);
		debugfs_create_bool("de_rtx_hw_ocp", 0644, charger->debug_entry,
				    &charger->pdata->hw_ocp_det);
		debugfs_create_u32("de_q_value", 0644, charger->debug_entry, &charger->de_q_value);
		debugfs_create_u32("de_chk_ocp_ms", 0644, charger->debug_entry,
				   &charger->rtx_ocp_chk_ms);
		debugfs_create_u32("de_rtx_delay_ms", 0644, charger->debug_entry,
				   &charger->rtx_total_delay);
	}

	/* can independently read battery capacity */
	dn = of_parse_phandle(of_node, "idt,fuel-gauge", 0);
	if (dn)
		schedule_delayed_work(&charger->fg_work, 0);

	/*
	 * Register notifier so we can detect changes on DC_IN
	 */
	INIT_DELAYED_WORK(&charger->notifier_work, p9221_notifier_work);
	charger->nb.notifier_call = p9221_notifier_cb;
	ret = power_supply_reg_notifier(&charger->nb);
	if (ret) {
		dev_err(&client->dev, "Fail to register notifier: %d\n", ret);
		return ret;
	}

	charger->log = logbuffer_register("wireless");
	if (IS_ERR(charger->log)) {
		ret = PTR_ERR(charger->log);
		dev_err(charger->dev,
			"failed to obtain logbuffer instance, ret=%d\n", ret);
		charger->log = NULL;
	}

	charger->rtx_log = logbuffer_register("rtx");
	if (IS_ERR(charger->rtx_log)) {
		ret = PTR_ERR(charger->rtx_log);
		dev_err(charger->dev,
			"failed to obtain rtx logbuffer instance, ret=%d\n",
			ret);
		charger->rtx_log = NULL;
	}

#if IS_ENABLED(CONFIG_GPIOLIB)
	if (charger->pdata->chip_id == P9412_CHIP_ID ||
	    charger->pdata->chip_id == P9222_CHIP_ID) {
		p9xxx_gpio_init(charger);
		charger->gpio.parent = &client->dev;
		charger->gpio.of_node = of_find_node_by_name(client->dev.of_node,
						charger->gpio.label);
		if (!charger->gpio.of_node)
			dev_err(&client->dev, "Failed to find %s DT node\n",
				charger->gpio.label);

		ret = devm_gpiochip_add_data(&client->dev, &charger->gpio, charger);
		dev_info(&client->dev, "%d GPIOs registered ret:%d\n",
			 charger->gpio.ngpio, ret);

	}
#endif

	dev_info(&client->dev, "p9221 Charger Driver Loaded\n");

	if (online) {
		charger->dc_psy = power_supply_get_by_name("dc");
		if (charger->dc_psy)
			power_supply_changed(charger->dc_psy);
	}

	/* prefill txid 1 with API revision number (1) */
	feature_update_cache(&charger->chg_features, 1, 1);
	return 0;
}

static int p9221_charger_remove(struct i2c_client *client)
{
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	cancel_delayed_work_sync(&charger->dcin_work);
	cancel_delayed_work_sync(&charger->charge_stats_work);
	cancel_delayed_work_sync(&charger->tx_work);
	cancel_delayed_work_sync(&charger->txid_work);
	cancel_delayed_work_sync(&charger->icl_ramp_work);
	cancel_delayed_work_sync(&charger->dcin_pon_work);
	cancel_delayed_work_sync(&charger->align_work);
	cancel_delayed_work_sync(&charger->rtx_work);
	cancel_delayed_work_sync(&charger->auth_dc_icl_work);
	cancel_delayed_work_sync(&charger->chk_rp_work);
	cancel_delayed_work_sync(&charger->chk_rtx_ocp_work);
	cancel_delayed_work_sync(&charger->chk_fod_work);
	cancel_work_sync(&charger->uevent_work);
	cancel_work_sync(&charger->rtx_disable_work);
	cancel_work_sync(&charger->rtx_reset_work);
	cancel_delayed_work_sync(&charger->power_mitigation_work);
	alarm_try_to_cancel(&charger->icl_ramp_alarm);
	alarm_try_to_cancel(&charger->auth_dc_icl_alarm);
	del_timer_sync(&charger->vrect_timer);
	del_timer_sync(&charger->align_timer);
	device_init_wakeup(charger->dev, false);
	cancel_delayed_work_sync(&charger->notifier_work);
	power_supply_unreg_notifier(&charger->nb);
	if (!IS_ERR_OR_NULL(charger->fg_psy))
		power_supply_put(charger->fg_psy);
	mutex_destroy(&charger->io_lock);
	mutex_destroy(&charger->stats_lock);
	mutex_destroy(&charger->chg_features.feat_lock);
	mutex_destroy(&charger->rtx_lock);
	mutex_destroy(&charger->auth_lock);
	mutex_destroy(&charger->renego_lock);
	if (charger->log)
		logbuffer_unregister(charger->log);
	if (charger->rtx_log)
		logbuffer_unregister(charger->rtx_log);

	wakeup_source_unregister(charger->align_ws);
	return 0;
}

static const struct i2c_device_id p9221_charger_id_table[] = {
	{ "p9221", 0 },
	{ "p9382", 0 },
	{ },
};
MODULE_DEVICE_TABLE(i2c, p9221_charger_id_table);

#ifdef CONFIG_OF
static struct of_device_id p9221_charger_match_table[] = {
	{ .compatible = "idt,p9221",},
	{ .compatible = "idt,p9222",},
	{ .compatible = "idt,p9382",},
	{ .compatible = "idt,p9412",},
	{},
};
#else
#define p9221_charger_match_table NULL
#endif

#ifdef CONFIG_PM_SLEEP
static int p9221_pm_suspend(struct device *dev)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	pm_runtime_get_sync(charger->dev);
	charger->resume_complete = false;
	pm_runtime_put_sync(charger->dev);

	return 0;
}

static int p9221_pm_resume(struct device *dev)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct p9221_charger_data *charger = i2c_get_clientdata(client);

	pm_runtime_get_sync(charger->dev);
	charger->resume_complete = true;
	if (charger->disable_irq) {
		enable_irq(charger->pdata->irq_int);
		charger->disable_irq = false;
	}
	pm_runtime_put_sync(charger->dev);

	return 0;
}
#endif
static const struct dev_pm_ops p9221_pm_ops = {
	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(p9221_pm_suspend, p9221_pm_resume)
};

static struct i2c_driver p9221_charger_driver = {
	.driver = {
		.name		= "p9221",
		.owner		= THIS_MODULE,
		.of_match_table = p9221_charger_match_table,
		.pm		= &p9221_pm_ops,
		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
	},
	.probe		= p9221_charger_probe,
	.remove		= p9221_charger_remove,
	.id_table	= p9221_charger_id_table,
};
module_i2c_driver(p9221_charger_driver);
MODULE_DESCRIPTION("IDT P9221 Wireless Power Receiver Driver");
MODULE_AUTHOR("Patrick Tjin <pattjin@google.com>");
MODULE_LICENSE("GPL");
