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

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

Merge "power: schgm-flashlite: cleanup schgm-flashlite driver"

parents 4e1c68c5 3ecdf835
Loading
Loading
Loading
Loading
+0 −39
Original line number Original line Diff line number Diff line
@@ -85,13 +85,6 @@ static void schgm_flashlite_parse_dt(struct smb_charger *chg)
		if (IS_BETWEEN(0, 100, val))
		if (IS_BETWEEN(0, 100, val))
			chg->flash_disable_soc = (val * 255) / 100;
			chg->flash_disable_soc = (val * 255) / 100;
	}
	}

	chg->headroom_mode = -EINVAL;
	rc = of_property_read_u32(node, "qcom,headroom-mode", &val);
	if (!rc) {
		if (IS_BETWEEN(FIXED_MODE, ADAPTIVE_MODE, val))
			chg->headroom_mode = val;
	}
}
}


bool is_flashlite_active(struct smb_charger *chg)
bool is_flashlite_active(struct smb_charger *chg)
@@ -151,13 +144,6 @@ void schgm_flashlite_torch_priority(struct smb_charger *chg,
	int rc;
	int rc;
	u8 reg;
	u8 reg;


	/*
	 * If torch is configured in default BOOST mode, skip any update in the
	 * mode configuration.
	 */
	if (chg->headroom_mode == FIXED_MODE)
		return;

	if ((mode != TORCH_BOOST_MODE) && (mode != TORCH_BUCK_MODE))
	if ((mode != TORCH_BOOST_MODE) && (mode != TORCH_BUCK_MODE))
		return;
		return;


@@ -209,31 +195,6 @@ int schgm_flashlite_init(struct smb_charger *chg)
		}
		}
	}
	}


	if (chg->headroom_mode != -EINVAL) {
		/*
		 * configure headroom management policy for
		 * flash and torch mode.
		 */
		reg = (chg->headroom_mode == FIXED_MODE)
					? FORCE_FLASH_BOOST_5V_BIT : 0;
		rc = smblite_lib_write(chg, SCHGM_FORCE_BOOST_CONTROL, reg);
		if (rc < 0) {
			pr_err("Couldn't write force boost control reg rc=%d\n",
					rc);
			return rc;
		}

		reg = (chg->headroom_mode == FIXED_MODE)
					? TORCH_PRIORITY_CONTROL_BIT : 0;
		rc = smblite_lib_write(chg,
					SCHGM_TORCH_PRIORITY_CONTROL_REG, reg);
		if (rc < 0) {
			pr_err("Couldn't force 5V boost in torch mode rc=%d\n",
					rc);
			return rc;
		}
	}

	if ((chg->flash_derating_soc != -EINVAL)
	if ((chg->flash_derating_soc != -EINVAL)
				|| (chg->flash_disable_soc != -EINVAL)) {
				|| (chg->flash_disable_soc != -EINVAL)) {
		/* Check if SOC based derating/disable is enabled */
		/* Check if SOC based derating/disable is enabled */
+0 −3
Original line number Original line Diff line number Diff line
@@ -21,9 +21,6 @@


#define SCHGM_FLASH_STATUS_5_REG		(SCHGM_FLASH_BASE + 0x0B)
#define SCHGM_FLASH_STATUS_5_REG		(SCHGM_FLASH_BASE + 0x0B)


#define SCHGM_FORCE_BOOST_CONTROL		(SCHGM_FLASH_BASE + 0x41)
#define FORCE_FLASH_BOOST_5V_BIT		BIT(0)

#define SCHGM_FLASH_S2_LATCH_RESET_CMD_REG	(SCHGM_FLASH_BASE + 0x44)
#define SCHGM_FLASH_S2_LATCH_RESET_CMD_REG	(SCHGM_FLASH_BASE + 0x44)
#define FLASH_S2_LATCH_RESET_BIT		BIT(0)
#define FLASH_S2_LATCH_RESET_BIT		BIT(0)


+6 −7
Original line number Original line Diff line number Diff line
@@ -16,10 +16,9 @@
#include <linux/ktime.h>
#include <linux/ktime.h>
#include "smblite-lib.h"
#include "smblite-lib.h"
#include "smblite-reg.h"
#include "smblite-reg.h"
#include "schgm-flash.h"
#include "step-chg-jeita.h"
#include "step-chg-jeita.h"
#include "storm-watch.h"
#include "storm-watch.h"
#include "schgm-flash.h"
#include "schgm-flashlite.h"


#define smblite_lib_err(chg, fmt, ...)		\
#define smblite_lib_err(chg, fmt, ...)		\
	pr_err("%s: %s: " fmt, chg->name,	\
	pr_err("%s: %s: " fmt, chg->name,	\
@@ -433,7 +432,7 @@ static void smblite_lib_uusb_removal(struct smb_charger *chg)
	vote(chg->pl_enable_votable_indirect, USBIN_I_VOTER, false, 0);
	vote(chg->pl_enable_votable_indirect, USBIN_I_VOTER, false, 0);
	vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, false, 0);
	vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, false, 0);
	vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true,
	vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true,
			is_flash_active(chg) ? USBIN_500UA : USBIN_100UA);
			is_flashlite_active(chg) ? USBIN_500UA : USBIN_100UA);


	/* Remove SW thermal regulation votes */
	/* Remove SW thermal regulation votes */
	vote(chg->usb_icl_votable, SW_THERM_REGULATION_VOTER, false, 0);
	vote(chg->usb_icl_votable, SW_THERM_REGULATION_VOTER, false, 0);
@@ -522,7 +521,7 @@ int smblite_lib_set_icl_current(struct smb_charger *chg, int icl_ua)
	/* suspend if 25mA or less is requested */
	/* suspend if 25mA or less is requested */
	bool suspend = (icl_ua <= USBIN_25UA);
	bool suspend = (icl_ua <= USBIN_25UA);


	schgm_flash_torch_priority(chg, suspend ? TORCH_BOOST_MODE :
	schgm_flashlite_torch_priority(chg, suspend ? TORCH_BOOST_MODE :
							TORCH_BUCK_MODE);
							TORCH_BUCK_MODE);
	/* Do not configure ICL from SW for DAM */
	/* Do not configure ICL from SW for DAM */
	if (smblite_lib_get_prop_typec_mode(chg) ==
	if (smblite_lib_get_prop_typec_mode(chg) ==
@@ -2017,7 +2016,7 @@ irqreturn_t smblite_usbin_uv_irq_handler(int irq, void *data)


unsuspend_input:
unsuspend_input:
		/* Force torch in boost mode to ensure it works with low ICL */
		/* Force torch in boost mode to ensure it works with low ICL */
		schgm_flash_torch_priority(chg, TORCH_BOOST_MODE);
		schgm_flashlite_torch_priority(chg, TORCH_BOOST_MODE);


		if (chg->aicl_max_reached) {
		if (chg->aicl_max_reached) {
			smblite_lib_dbg(chg, PR_MISC,
			smblite_lib_dbg(chg, PR_MISC,
@@ -2210,7 +2209,7 @@ static void update_sw_icl_max(struct smb_charger *chg,
						USB_PSY_VOTER)) {
						USB_PSY_VOTER)) {
			/* if flash is active force 500mA */
			/* if flash is active force 500mA */
			vote(chg->usb_icl_votable, USB_PSY_VOTER, true,
			vote(chg->usb_icl_votable, USB_PSY_VOTER, true,
					is_flash_active(chg) ?
					is_flashlite_active(chg) ?
					USBIN_500UA : USBIN_100UA);
					USBIN_500UA : USBIN_100UA);
		}
		}
		vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, false, 0);
		vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, false, 0);
@@ -2516,7 +2515,7 @@ static void typec_src_removal(struct smb_charger *chg)


	/* reset input current limit voters */
	/* reset input current limit voters */
	vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true,
	vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true,
			is_flash_active(chg) ? USBIN_500UA : USBIN_100UA);
			is_flashlite_active(chg) ? USBIN_500UA : USBIN_100UA);
	vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0);
	vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0);


	/* reset parallel voters */
	/* reset parallel voters */
+0 −4
Original line number Original line Diff line number Diff line
@@ -144,14 +144,10 @@ enum smb_irq_index {
	VREG_OK_IRQ,
	VREG_OK_IRQ,
	ILIM_S2_IRQ,
	ILIM_S2_IRQ,
	ILIM_S1_IRQ,
	ILIM_S1_IRQ,
	VOUT_DOWN_IRQ,
	VOUT_UP_IRQ,
	FLASH_STATE_CHANGE_IRQ,
	FLASH_STATE_CHANGE_IRQ,
	TORCH_REQ_IRQ,
	TORCH_REQ_IRQ,
	FLASH_EN_IRQ,
	FLASH_EN_IRQ,
	SDAM_STS_IRQ,
	/* END */
	/* END */
	SMB_IRQ_MAX,
};
};


enum chg_term_config_src {
enum chg_term_config_src {