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

Commit 14ce3d92 authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

power: qpnp-smb2: Update the SMB2 charger driver



Update the QPNP SMB2 charger driver for the
msm-3.18 kernel. The following are the updates -

1. Support the legacy SPMI driver design
2. Remove USB psy (implemented in the USB software stack)
3. Add present and charger-type power supply notifications

CRs-Fixed: 2076000
Change-Id: Ic75231efd460579754a46ca8745880b037f5daf3
Signed-off-by: default avatarAnkit Sharma <ansharma@codeaurora.org>
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 0fda0080
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -927,9 +927,9 @@ static int pl_notifier_call(struct notifier_block *nb,
	if (ev != PSY_EVENT_PROP_CHANGED)
		return NOTIFY_OK;

	if ((strcmp(psy->desc->name, "parallel") == 0)
	    || (strcmp(psy->desc->name, "battery") == 0)
	    || (strcmp(psy->desc->name, "main") == 0))
	if ((strcmp(psy->name, "parallel") == 0)
	    || (strcmp(psy->name, "battery") == 0)
	    || (strcmp(psy->name, "main") == 0))
		schedule_delayed_work(&chip->status_change_work, 0);

	return NOTIFY_OK;
+112 −669

File changed.

Preview size limit exceeded, changes collapsed.

+186 −292

File changed.

Preview size limit exceeded, changes collapsed.

+7 −28
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
#include <linux/irqreturn.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/consumer.h>
#include <linux/extcon.h>
#include "storm-watch.h"

enum print_reason {
@@ -136,12 +135,6 @@ struct smb_irq_info {
	int				irq;
};

static const unsigned int smblib_extcon_cable[] = {
	EXTCON_USB,
	EXTCON_USB_HOST,
	EXTCON_NONE,
};

struct smb_regulator {
	struct regulator_dev	*rdev;
	struct regulator_desc	rdesc;
@@ -190,9 +183,6 @@ struct smb_params {
	struct smb_chg_param	dc_icl_div2_mid_hv;
	struct smb_chg_param	dc_icl_div2_hv;
	struct smb_chg_param	jeita_cc_comp;
	struct smb_chg_param	step_soc_threshold[4];
	struct smb_chg_param	step_soc;
	struct smb_chg_param	step_cc_delta[5];
	struct smb_chg_param	freq_buck;
	struct smb_chg_param	freq_boost;
};
@@ -224,7 +214,7 @@ struct reg_info {
struct smb_charger {
	struct device		*dev;
	char			*name;
	struct regmap		*regmap;
	struct spmi_device	*spmi;
	struct smb_irq_info	*irq_info;
	struct smb_params	param;
	struct smb_iio		iio;
@@ -243,13 +233,11 @@ struct smb_charger {
	struct mutex		vconn_oc_lock;

	/* power supplies */
	struct power_supply		*batt_psy;
	struct power_supply		batt_psy;
	struct power_supply		*usb_psy;
	struct power_supply		*dc_psy;
	struct power_supply		dc_psy;
	struct power_supply		*bms_psy;
	struct power_supply_desc	usb_psy_desc;
	struct power_supply		*usb_main_psy;
	struct power_supply		*usb_port_psy;
	struct power_supply		usb_main_psy;
	enum power_supply_type		real_charger_type;

	/* notifiers */
@@ -261,7 +249,6 @@ struct smb_charger {
	/* regulators */
	struct smb_regulator	*vbus_vreg;
	struct smb_regulator	*vconn_vreg;
	struct regulator	*dpdm_reg;

	/* votables */
	struct votable		*dc_suspend_votable;
@@ -287,7 +274,6 @@ struct smb_charger {
	struct work_struct	rdstd_cc2_detach_work;
	struct delayed_work	hvdcp_detect_work;
	struct delayed_work	ps_change_timeout_work;
	struct delayed_work	step_soc_req_work;
	struct delayed_work	clear_hdc_work;
	struct work_struct	otg_oc_work;
	struct work_struct	vconn_oc_work;
@@ -329,6 +315,7 @@ struct smb_charger {
	bool			pr_swap_in_progress;
	int			typec_mode;
	int			usb_icl_change_irq_enabled;
	bool			skip_usb_notification;

	/* workaround flag */
	u32			wa_flags;
@@ -337,9 +324,6 @@ struct smb_charger {
	int			boost_current_ua;
	int			temp_speed_reading_count;

	/* extcon for VBUS / ID notification to USB for uUSB */
	struct extcon_dev	*extcon;

	/* battery profile */
	int			batt_profile_fcc_ua;
	int			batt_profile_fv_uv;
@@ -349,6 +333,7 @@ struct smb_charger {
	int			pulse_cnt;
};


int smblib_read(struct smb_charger *chg, u16 addr, u8 *val);
int smblib_masked_write(struct smb_charger *chg, u16 addr, u8 mask, u8 val);
int smblib_write(struct smb_charger *chg, u16 addr, u8 val);
@@ -383,9 +368,6 @@ int smblib_vconn_regulator_is_enabled(struct regulator_dev *rdev);
irqreturn_t smblib_handle_debug(int irq, void *data);
irqreturn_t smblib_handle_otg_overcurrent(int irq, void *data);
irqreturn_t smblib_handle_chg_state_change(int irq, void *data);
irqreturn_t smblib_handle_step_chg_state_change(int irq, void *data);
irqreturn_t smblib_handle_step_chg_soc_update_fail(int irq, void *data);
irqreturn_t smblib_handle_step_chg_soc_update_request(int irq, void *data);
irqreturn_t smblib_handle_batt_temp_changed(int irq, void *data);
irqreturn_t smblib_handle_batt_psy_changed(int irq, void *data);
irqreturn_t smblib_handle_usb_psy_changed(int irq, void *data);
@@ -423,9 +405,6 @@ int smblib_get_prop_batt_current_now(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_batt_temp(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_step_chg_step(struct smb_charger *chg,
				union power_supply_propval *val);

int smblib_set_prop_input_suspend(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_set_prop_batt_capacity(struct smb_charger *chg,