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

Commit 9297d0f1 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: Add snapshot of STC311x FG driver"

parents 14c4ecb0 e9ed4a5a
Loading
Loading
Loading
Loading
+120 −0
Original line number Diff line number Diff line
STC311x Fuel Gauge device

STC311x FG provides interface to clients to read properties related
to the battery. Its main function is to retrieve the State of Charge (SOC),
a 0-100 percentage representing the amount of charge left in the battery.

- compatible
	Usage:		Required
	Value:		<string>
	Definition:	Must be  "st,stc311x" for the driver.

- reg
	Usage:		Required
	Value:		<u32>
	Definition:	The device 7-bit I2C address.

- st,float-voltage-mv
	Usage:		Required
	Value type:	<u32> in mV.
	Definition:	Float Voltage in mV - the maximum voltage up to which
			the battery is charged.

- st,rsense-mohm
	Usage:		Required
	Value type:	<u32> in mohm.
	Definition:	Current sense resistance value.

- st,nom-capacity-mah
	Usage:		Required
	Value type:	<u32> in mah.
	Definition:	This specifies nominal capacity of battery.

- st,rbatt-mohm
	Usage:		Required
	Value type:	<u32> in mohm.
	Definition:	This specifies battery internal resistance.

- st,ocv-tbl
	Usage:		Required
	Value type:	<u16 array> in mV.
	Definition:	This specifies an array of battery open circuit voltages at
			different SOC points.
			SOC points: [0 3 6 10 15 20 25 30 40 50 60 65 70 80 90
					100].

- st,vmtemp-tbl
	Usage:		Required
	Value type:	<u16 array>
	Definition:	This specifies an array of VCNF compensation table at
			different temperatures.

- st,temp-tbl
	Usage:		Required
	Value type:	<s16 array in DeciDegC>
	Definition:	This specifies an array of temperature points used in
			vtemp table and adaptive capacity tables.

- st,cutoff-voltage-mv
	Usage:		Optional
	Value type:	<u32> in mV
	Definition:	This is the minimum allowed system voltage. The FG
			will report SOC = 0 at this volatge. This value is
			also used to configure alarm voltage threshold.
			If not specified default value is set to 3400mV.

- st,alarm-soc
	Usage:		Optional
	Value type:	<u32> in %
	Definition:	This is the alarm SOC threshold.
			If not specified default value is set to 10%.

- st,term-current-ma
	Usage:		Optional
	Value type:	<u32> in mA
	Definition:	This is the maximum current threshold limit used to
			decide end of charge.
			If not specified value is set to

- st,relax-current-ma
	Usage:		Optional
	Value type:	<u32> in mA
	Definition:	This is the current threshold to decide automatic mode
			switch between voltage and moxec mode.
			If not specified value is set to

- st,adaptive-capacity-tbl
	Usage:		Optional
	Value type:	<u16 array, each element is in 0.1%>
	Definition:	This table specifies capacity degradation with
			temperature.

- st,force-voltage-mode
	Usage:		Optional
	Value type:	Boolean
	Definition:	This is to force FG always in low power voltage mode.

Example:
	st-fg@70 {
		compatible = "st,stc3117";
		reg = <0x70>;

		st,rbatt-mohm = <210>;
		st,nom-capacity-mah = <1500>;
		st,rsense-mohm = <10>;
		st,float-voltage-mv = <4200>;

		st,alarm-soc = <10>;
		st,alarm-voltage-mv = <3400>;

		st,term-current-ma = <150>;
		st,relax-current-ma = <200>;

		st,adaptive-capacity-tbl = /bits/ 16 <0 0 0 5 13 42 71>;
		st,ocv-tbl = /bits/ 16 <3300 3528 3667 3731 3753 3765 3772
					3792 3827 3900 3929 3957 3513 4072
					4167>;
		st,vmtemp-tbl = /bits/ 16 <85 90 100 160 320 440 840>
		st,temp-tbl = /bits/ 16 <60 40 25 10 0 (-10) (-20)>;
	};
+10 −0
Original line number Diff line number Diff line
@@ -495,6 +495,16 @@ config QPNP_SMBCHARGER
	  The driver also offers relevant information to userspace via the
	  power supply framework.

config FUELGAUGE_STC3117
	tristate "STC3117 fuel gauge driver"
	default n
	depends on I2C
	help
	  Say Y to include support
	  for STC3117 fuel gauge driver for batteries.
	  This driver source code implemented
	  all functions for STC3117 fuel gauge.

config QPNP_FG
	tristate "QPNP fuel gauge driver"
	depends on SPMI || MSM_SPMI
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o
obj-$(CONFIG_CHARGER_BQ2415X)	+= bq2415x_charger.o
obj-$(CONFIG_CHARGER_BQ24190)	+= bq24190_charger.o
obj-$(CONFIG_CHARGER_BQ24735)	+= bq24735-charger.o
obj-$(CONFIG_FUELGAUGE_STC3117)	+= stc3117_battery.o
obj-$(CONFIG_POWER_AVS)		+= avs/
obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
obj-$(CONFIG_SMB349_USB_CHARGER)   += smb349-charger.o
+1636 −0

File added.

Preview size limit exceeded, changes collapsed.

+75 −0
Original line number Diff line number Diff line

#if CONFIG_BATTERY_STC3117

int null_fn(void)
{
	return 0;                // for discharging status
}

int Temperature_fn(void)
{
	return (25);
}

static struct stc311x_platform_data stc3117_data = {
	.battery_online = NULL,
	.charger_online = null_fn, 		// used in stc311x_get_status()
	.charger_enable = null_fn,		// used in stc311x_get_status()
	.power_supply_register = NULL,
	.power_supply_unregister = NULL,

	.Vmode= 0,       /*REG_MODE, BIT_VMODE 1=Voltage mode, 0=mixed mode */
	.Alm_SOC = 10,      /* SOC alm level %*/
	.Alm_Vbat = 3600,   /* Vbat alm level mV*/
	.CC_cnf = 525,      /* nominal CC_cnf, coming from battery characterisation*/
	.VM_cnf = 558,      /* nominal VM cnf , coming from battery characterisation*/
	.Rint = 200,			/* nominal internal impedance*/
	.Cnom = 2600,       /* nominal capacity in mAh, coming from battery characterisation*/
	.Rsense = 10,       /* sense resistor mOhms*/
	.RelaxCurrent = 150, /* current for relaxation in mA (< C/20) */
	.Adaptive = 1,     /* 1=Adaptive mode enabled, 0=Adaptive mode disabled */

	/* Elentec Co Ltd Battery pack - 80 means 8% */
	.CapDerating[6] = 71,   /* capacity derating in 0.1%, for temp = -20C */
	.CapDerating[5] = 42,   /* capacity derating in 0.1%, for temp = -10C */
	.CapDerating[4] = 13,   /* capacity derating in 0.1%, for temp = 0C */
	.CapDerating[3] = 5,   /* capacity derating in 0.1%, for temp = 10C */
	.CapDerating[2] = 0,   /* capacity derating in 0.1%, for temp = 25C */
	.CapDerating[1] = 0,   /* capacity derating in 0.1%, for temp = 40C */
	.CapDerating[0] = 0,   /* capacity derating in 0.1%, for temp = 60C */

	.OCVValue[15] = 0,   /* OCV curve adjustment */
	.OCVValue[14] = 0,   /* OCV curve adjustment */
	.OCVValue[13] = 0,   /* OCV curve adjustment */
	.OCVValue[12] = 0,   /* OCV curve adjustment */
	.OCVValue[11] = 0,   /* OCV curve adjustment */
	.OCVValue[10] = 0,   /* OCV curve adjustment */
	.OCVValue[9] = 0,    /* OCV curve adjustment */
	.OCVValue[8] = 0,    /* OCV curve adjustment */
	.OCVValue[7] = 0,    /* OCV curve adjustment */
	.OCVValue[6] = 0,    /* OCV curve adjustment */
	.OCVValue[5] = 0,    /* OCV curve adjustment */
	.OCVValue[4] = 0,    /* OCV curve adjustment */
	.OCVValue[3] = 0,    /* OCV curve adjustment */
	.OCVValue[2] = 0,    /* OCV curve adjustment */
	.OCVValue[1] = 0,    /* OCV curve adjustment */
	.OCVValue[0] = 0,    /* OCV curve adjustment */

	/*if the application temperature data is preferred than the STC3117 temperature*/
	.ExternalTemperature = Temperature_fn, /*External temperature fonction, return C*/
	.ForceExternalTemperature = 0, /* 1=External temperature, 0=STC3117 temperature */

};
#endif


static struct i2c_board_info __initdata beagle_i2c2_boardinfo[] = {

#if CONFIG_BATTERY_STC3117
	{
		I2C_BOARD_INFO("stc3117", 0x70),
			.platform_data = &stc3117_data,
	},
#endif

};
Loading