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

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

Merge changes I3f3013c5,Icd2bac7f into msm-4.14

* changes:
  defconfig: sdm855: enable GEN4 FG driver
  power: qpnp-fg-gen4: Add GEN4 FG driver
parents 355d75fe f92a3df3
Loading
Loading
Loading
Loading
+324 −0
Original line number Diff line number Diff line
Qualcomm Technologies, Inc. PMIC Fuel Gauge Gen4 Device

QTI PMIC FG Gen4 device provides interface to the clients to read properties
related to the battery. Its main function is to retrieve the State of Charge
(SOC), in percentage scale representing the amount of charge left in the
battery.

=======================
Required Node Structure
=======================

FG Gen4 device must be described in two levels of device nodes.  The first
level describes the FG Gen4 device.  The second level describes one or more
peripherals managed by FG Gen4 driver. All the peripheral specific parameters
such as base address, interrupts etc., should be under second level node.

====================================
First Level Node - FG Gen4 device
====================================

- compatible
	Usage:      required
	Value type: <string>
	Definition: Should be "qcom,fg-gen4".

- qcom,pmic-revid
	Usage:      required
	Value type: <phandle>
	Definition: Should specify the phandle of PMIC revid module. This is
		    used to identify the PMIC subtype.

- qcom,fg-cutoff-voltage
	Usage:      optional
	Value type: <u32>
	Definition: The voltage (in mV) where the fuel gauge will steer the SOC
		    to be zero. For example, if the cutoff voltage is set to
		    3400mv, the fuel gauge will try to count SoC so that the
		    battery SOC will be 0 when it is 3400 mV. If this property
		    is not specified, then the default value used will be
		    3000 mV.

- qcom,fg-empty-voltage
	Usage:      optional
	Value type: <u32>
	Definition: The voltage threshold (in mV) based on which the empty soc
		    interrupt will be triggered. When the empty soc interrupt
		    fires, battery soc will be set to 0 and the userspace will
		    be notified via the power supply framework. The userspace
		    will read 0% soc and immediately shutdown. If this property
		    is not specified, then the default value used will be
		    2812 mV.

- qcom,fg-sys-term-current
	Usage:      optional
	Value type: <u32>
	Definition: Battery current (in mA) at which the fuel gauge will try to
		    scale towards 100%. When the charge current goes above this
		    the SOC should be at 100%. If this property is not
		    specified, then the default value used will be -125 mA.
		    This value has to be specified in negative values for
		    the charging current.

- qcom,fg-cutoff-current
	Usage:      optional
	Value type: <u32>
	Definition: Minimum Battery current (in mA) used for cutoff SOC
		    estimate. If this property is not specified, then a default
		    value of 200 mA will be applied.

- qcom,fg-delta-soc-thr
	Usage:      optional
	Value type: <u32>
	Definition: Percentage of SOC increase upon which the delta monotonic &
		    battery SOC interrupts will be triggered. If this property
		    is not specified, then the default value will be 1.
		    Possible values are in the range of 0 to 12.

- qcom,fg-esr-timer-chg-fast
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: Number of cycles between ESR pulses while the battery is
		    charging for fast calibration. Array of 2 elements if
		    specified.
		    Element 0 - Retry value for timer
		    Element 1 - Maximum value for timer

- qcom,fg-esr-timer-dischg-fast
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: Number of cycles between ESR pulses while the battery is
		    discharging for fast calibration. Array of 2 elements if
		    specified.
		    Element 0 - Retry value for timer
		    Element 1 - Maximum value for timer

- qcom,fg-esr-timer-chg-slow
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: Number of cycles between ESR pulses while the battery is
		    charging for default calibration. Array of 2 elements if
		    specified.
		    Element 0 - Retry value for timer
		    Element 1 - Maximum value for timer

- qcom,fg-esr-timer-dischg-slow
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: Number of cycles between ESR pulses while the battery is
		    discharging for default calibration. Array of 2 elements if
		    specified.
		    Element 0 - Retry value for timer
		    Element 1 - Maximum value for timer

- qcom,fg-esr-pulse-thresh-ma
	Usage:      optional
	Value type: <u32>
	Definition: ESR pulse qualification threshold in mA. If this is not
		    specified, a default value of 110 mA will be configured.
		    Allowed values are from 1 to 1000.

- qcom,fg-esr-meas-curr-ma
	Usage:      optional
	Value type: <u32>
	Definition: ESR measurement current in mA. If this is not specified,
		    a default value of 120 mA will be configured. Allowed
		    values are 60, 120, 180 and 240.

- qcom,fg-batt-temp-delta
	Usage:      optional
	Value type: <u32>
	Definition: Battery temperature delta interrupt threshold. Possible
		    values are: 0, 1, 2 and 3. Unit is in Kelvin or Celsius.

- qcom,fg-batt-temp-cold-thresh
	Usage:      optional
	Value type: <u32>
	Definition: Battery temperature cold interrupt threshold. Allowed
		    values are from -128 to 127. Unit is in Kelvin or Celsius.

- qcom,fg-batt-temp-hot-thresh
	Usage:      optional
	Value type: <u32>
	Definition: Battery temperature hot interrupt threshold. Allowed
		    values are from -128 to 127. Unit is in Kelvin or Celsius.

- qcom,fg-batt-temp-hyst
	Usage:      optional
	Value type: <u32>
	Definition: Battery temperature hysteresis threshold. This will be
		    applicable only if the cold and hot thresholds are
		    specified. Possible values are: 0, 1, 2 and 3. Unit is in
		    Kelvin or Celsius.

- qcom,fg-force-load-profile
	Usage:      optional
	Value type: <empty>
	Definition: If set, battery profile will be force loaded if the profile
		    loaded earlier by bootloader doesn't match with the profile
		    available in the device tree.

- qcom,hold-soc-while-full
	Usage:      optional
	Value type: <empty>
	Definition: A boolean property that when defined holds SOC at 100% when
		    the battery is full.

- qcom,linearize-soc
	Usage:      optional
	Value type: <empty>
	Definition: A boolean property that when defined linearizes SOC when
		    the SOC drops after charge termination monotonically to
		    improve the user experience. This is applicable only if
		    "qcom,hold-soc-while-full" is specified.

- qcom,ki-coeff-soc-dischg
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: Array of monotonic SOC threshold values to change the ki
		    coefficient for medium discharge current during discharge.
		    This should be defined in the ascending order and in the
		    range of 0-100. Array limit is set to 3.

- qcom,ki-coeff-med-dischg
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: Array of ki coefficient values for medium discharge current
		    during discharge. These values will be applied when the
		    monotonic SOC goes below the SOC threshold specified under
		    qcom,ki-coeff-soc-dischg. Array limit is set to 3. This
		    property should be specified if qcom,ki-coeff-soc-dischg
		    is specified to make it fully functional. Value has no
		    unit. Allowed range is 62 to 15564 in micro units.

- qcom,ki-coeff-hi-dischg
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: Array of ki coefficient values for high discharge current
		    during discharge. These values will be applied when the
		    monotonic SOC goes below the SOC threshold specified under
		    qcom,ki-coeff-soc-dischg. Array limit is set to 3. This
		    property should be specified if qcom,ki-coeff-soc-dischg
		    is specified to make it fully functional. Value has no
		    unit. Allowed range is 62 to 15564 in micro units.

- qcom,fg-rconn-uohms
	Usage:      optional
	Value type: <u32>
	Definition: Battery connector resistance (Rconn) in microohms. If it's
		    already configured in bootloader, then it will not be
		    configured again by GEN4 FG driver.

- qcom,slope-limit-temp-threshold
	Usage:      optional
	Value type: <u32>
	Definition: Battery temperature threshold to decide when slope limit
		    coefficients should be applied along with charging status.
		    Unit is in decidegC.

- qcom,slope-limit-coeffs
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: A list of integers which holds the slope limit coefficients
		    in the following order. Allowed size is 4. Possible values
		    are from 123 to 31128. Unit is in micro-percentage.
		    Element 0 - Low temperature discharging
		    Element 1 - Low temperature charging
		    Element 2 - High temperature discharging
		    Element 3 - High temperature charging
		    These coefficients have to be specified along with the
		    property "qcom,slope-limit-temp-threshold" to make dynamic
		    slope limit adjustment functional.

==========================================================
Second Level Nodes - Peripherals managed by FG Gen4 driver
==========================================================
- reg
	Usage:      required
	Value type: <prop-encoded-array>
	Definition: Addresses and sizes for the specified peripheral

- interrupts
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: Interrupt mapping as per the interrupt encoding

- interrupt-names
	Usage:      optional
	Value type: <stringlist>
	Definition: Interrupt names.  This list must match up 1-to-1 with the
		    interrupts specified in the 'interrupts' property.

========
Example
========

pm855b_fg: qpnp,fg {
	compatible = "qcom,fg-gen4";
	#address-cells = <1>;
	#size-cells = <1>;
	qcom,pmic-revid = <&pm855b_revid>;
	status = "okay";

	qcom,fg-batt-soc@4000 {
		status = "okay";
		reg = <0x4000 0x100>;
		interrupts = <0x2 0x40 0x0 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x40 0x1 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x40 0x2 IRQ_TYPE_EDGE_RISING>,
			     <0x2 0x40 0x3 IRQ_TYPE_EDGE_RISING>,
			     <0x2 0x40 0x4 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x40 0x5 IRQ_TYPE_EDGE_RISING>,
			     <0x2 0x40 0x6 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x40 0x7 IRQ_TYPE_EDGE_BOTH>;
		interrupt-names = "soc-update",
				  "soc-ready",
				  "bsoc-delta",
				  "msoc-delta",
				  "msoc-low",
				  "msoc-empty",
				  "msoc-high",
				  "msoc-full";

	};

	qcom,fg-batt-info@4100 {
		status = "okay";
		reg = <0x4100 0x100>;
		interrupts = <0x2 0x41 0x0 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x41 0x1 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x41 0x3 IRQ_TYPE_EDGE_BOTH>;
		interrupt-names = "vbatt-low",
				  "vbatt-pred-delta",
				  "esr-delta";
	};

	qcom,adc-rr@4200 {
		status = "okay";
		reg = <0x4200 0x100>;
		interrupts = <0x2 0x42 0x0 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x42 0x1 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x42 0x2 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x42 0x3 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x42 0x4 IRQ_TYPE_EDGE_BOTH>;
		interrupt-names = "batt-missing",
				  "batt-id",
				  "batt-temp-delta",
				  "batt-temp-hot",
				  "batt-temp-cold";
	};

	qcom,fg-memif@4300 {
		status = "okay";
		reg = <0x4300 0x100>;
		interrupts = <0x2 0x43 0x0 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x43 0x1 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x43 0x2 IRQ_TYPE_EDGE_BOTH>,
			     <0x2 0x43 0x3 IRQ_TYPE_EDGE_BOTH>,
		interrupt-names = "ima-rdy",
				  "ima-xcp",
				  "dma-xcp",
				  "dma-grant",
	};

};
+1 −0
Original line number Diff line number Diff line
@@ -311,6 +311,7 @@ CONFIG_POWER_RESET_QCOM=y
CONFIG_QCOM_DLOAD_MODE=y
CONFIG_POWER_RESET_XGENE=y
CONFIG_POWER_RESET_SYSCON=y
CONFIG_QPNP_FG_GEN4=y
CONFIG_QPNP_SMB5=y
CONFIG_THERMAL=y
CONFIG_THERMAL_WRITABLE_TRIPS=y
+1 −0
Original line number Diff line number Diff line
@@ -320,6 +320,7 @@ CONFIG_POWER_RESET_QCOM=y
CONFIG_QCOM_DLOAD_MODE=y
CONFIG_POWER_RESET_XGENE=y
CONFIG_POWER_RESET_SYSCON=y
CONFIG_QPNP_FG_GEN4=y
CONFIG_QPNP_SMB5=y
CONFIG_THERMAL=y
CONFIG_THERMAL_WRITABLE_TRIPS=y
+10 −0
Original line number Diff line number Diff line
@@ -9,6 +9,16 @@ config QPNP_FG_GEN3
	  the fuel gauge. The state of charge is reported through a BMS power
	  supply property and also sends uevents when the capacity is updated.

config QPNP_FG_GEN4
	tristate "QPNP GEN4 fuel gauge driver"
	depends on MFD_SPMI_PMIC
	help
	  Say Y here to enable the GEN4 Fuel Gauge driver. This adds support
	  for battery fuel gauging and state of charge of battery connected to
	  the device that has QTI PMICs like PM855B. The state of charge is
	  reported through a BMS power supply property and also sends uevents
	  when the capacity is updated.

config SMB1355_SLAVE_CHARGER
	tristate "SMB1355 Slave Battery Charger"
	depends on MFD_I2C_PMIC
+1 −0
Original line number Diff line number Diff line
obj-$(CONFIG_QPNP_FG_GEN3)     += qpnp-fg-gen3.o fg-memif.o fg-util.o
obj-$(CONFIG_QPNP_FG_GEN4)     += qpnp-fg-gen4.o fg-memif.o fg-util.o pmic-voter.o
obj-$(CONFIG_SMB1355_SLAVE_CHARGER)   += smb1355-charger.o pmic-voter.o
obj-$(CONFIG_QPNP_SMB2)		+= step-chg-jeita.o battery.o qpnp-smb2.o smb-lib.o pmic-voter.o storm-watch.o
obj-$(CONFIG_SMB138X_CHARGER)	+= step-chg-jeita.o smb138x-charger.o smb-lib.o pmic-voter.o storm-watch.o battery.o
Loading