On debug setups where the battery is not present, we need a way
to fake battery capacity instead of reporting some incorrect
/non-existent value. Provide means for the userspace to setup
a fake battery capacity.
Change-Id: Iff3ee1009d9c3215433cc267f016ef9cf2a9bff2
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Implement VOLTAGE_MAX_DESIGN to expose the battery float voltage. This
property will reflect the values read from battery profile and will
will be used for setting the max voltage on charging chips.
Change-Id: I4b9028f8930ac2f3de6c043fa145494f37322160
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Currently the name of the votable that suspends usb is INPUT_SUSPEND.
However, the PMI has two inputs - USB and DC. The dc suspending votable
is correctly named DC_SUSPEND. So rename the INPUT_SUSPEND to an
appropriate name - USB_SUSPEND.
Change-Id: Ia5ea1b139f5e9d560dc6492aa9fc13ffeeda83ca
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
The location of some fuel gauge SRAM registers have changed in
PMICOBALT v2. Add a new SRAM register map for v2 to handle these changes.
Change-Id: I1fcfce8e56b1d4e8b8f54457193cd547fb5e3de7
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Buck damage was seen to go away once the dead time were increased
in addition to increasing the OOB comparator threshold.
CRs-Fixed: 1055113
Change-Id: I8979d203fc7c35ec23e23874c8dd8f980a1cc619
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Commit 85635da429 ("qcom-charger: smb138x: fix buck damage on
v1.1 hardware") introduced wa_flags as the first member
in the struct. However there are implict assumptions in the driver that
the first member is the library structure. This causes memory corruption
and an eventual watch dog bite reset.
Fix it by ensuring that the library struct is explicitly initialized
from the parent struct.
CRs-Fixed: 1055113
Change-Id: I38474a228ec7b245dc330b4a37847c9f1bf29c2a
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
ESR pulses consume too much power during sleep states.
Add device tree properties to allow configuration of the ESR timing during
charging, discharging while awake, and discharging while asleep.
Configure these new device tree properties to increase the ESR timer
while in a sleep state to save power.
Change-Id: I673ab1a5713023ac4ab0271fec8d9a053df1c046
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
In the suspend path a wakelock should not be held. Add a flag to bypass
holding a wakelock during an SRAM read or write so that they can be used
in the suspend path.
Change-Id: I74ccae4e9b5aeccf261cc94e9bb89138d7d48345
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Device reboot to edl, it's for switching device to emergency dload mode.
So it's need to keep device to do warm reset.
Change-Id: I8f5d0845c6f2d37ea740949ce56e02c4cc7412be
Signed-off-by: Lijuan Gao <lijuang@codeaurora.org>
Add callback function members in data structure smb_chg_param to
handle data conversions other than the default provided in the
existing framework.
CRs-Fixed: 1052854
Change-Id: I0f4f0e1e67f3097b567db006a7826a2d1fd7c2d6
Signed-off-by: Harry Yang <harryy@codeaurora.org>
Buck damage was observed because the OOB comparator activated
when HSFET was on, causing a direct short from VBUS to ground. Fix this
on V1.1 by increasing the OOB comparator threshold. On 2.0 this is fixed
by ensuring the OOB comparator activates only after HSFET minimum on
time. This in turn guarantees that HSFET and LSFET won't be on at the
same time.
Since the driver needs to detect the version of the smb, make use of the
qpnp-revid module.
CRs-Fixed: 1055113
Change-Id: I0a7946db2f1bdacf1974fb508da46f2ed4dadadc
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
A wakelock is held when reading an SRAM prop. A wakelock is already held
when the SRAM read happens, so it is not necessary to hold a wakelock
again. Remove it.
Change-Id: I7bf5cafd34bd9187a13043f0995a49d2f26b8b6b
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Import batt capacity status from bms, and notify userspace.
CRs-Fixed: 1048135
Change-Id: I76357e44452a8c16fe96df47af06ddab021c8f3f
Signed-off-by: Harry Yang <harryy@codeaurora.org>
Add ICL vote to disable parallel charging on charger removal, as ICL
drops below the input threshold for parallel charging.
CRs-Fixed: 1049921
Change-Id: I8112070f7dd1eb385996b4f228ad288b51771e25
Signed-off-by: Harry Yang <harryy@codeaurora.org>
There are several ways that the parallel charger can be enabled, and
disabled. Currently charging is enabled by default, but the hardware has
the option to disable the parallel charger via the CHG_EN pin on the
parallel charger. The parallel charger driver controls when the
parallel charger is enabled via the input suspend bit.
To better understand the state of the parallel charger add two power
supply properties to the parallel power supply:
CHARGING_ENABLED - Reflects whether the parallel charger is
enabled by any source.
PIN_ENABLED - Reflects whether hardware has voted to enable
the parallel charger.
Change-Id: I725245178ab02c5ec39b89998f5c2ca3d494c8ee
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Hardware disables the parallel charger via the CHG_EN pin. Add a new
property called PIN_ENABLED which reflects the status of the CHG_EN pin.
Change-Id: I79f95b145176b66d6b8cec5a21922ea16c2c8206
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
CHARGER_TEMP reflects the temperature of the charging chip, and
CHARGER_TEMP_MAX reflects the temperature threshold at which the
hardware will take action to reduce the temperature of the charger.
Change-Id: I9cba8e370c753ac5aa33252fce0ea446f061b4c0
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Currently some hardware default charge settings are modified with
software default charge settings. Remove the software default settings,
and use only the device tree properties for changing the hardware
defaults.
Change-Id: I02a0cbbf547aacc5e813d027a2f3623cc01e1dd6
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Currently the charge cycle continues while the battery is OV. Configure
the charger to end the charge cycle while battery is OV.
Change-Id: I6fc333e15c5f0410c6b560b2a7005a1752f5f936
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
When a Type-C legacy cable is connected to the phone but left unconnected
on the other side an interrupt storm can be observed which is caused by
the vbus-error interrupt trigger. Disable this interrupt trigger.
Change-Id: I5342c58acc83ecff4bf5f8e425de94daa1dabb50
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Add support for WiPower by instantiating DC power supply and the required
properties.
CRs-Fixed: 1044422
Change-Id: I81d2e3b67bf55460f40406328c5ad8c40851033a
Signed-off-by: Harry Yang <harryy@codeaurora.org>
Fix the following things in fg-util.c which is included by GEN3
FG driver:
- Possible out of bounds access in fg_sram_dfs_reg_write() when
using bytes_read from sscanf
- Fix uninitialized usage of variable in write_next_line_to_log()
Change-Id: If9e7ba5632d1b5f99d91bda6276d9123c37e4dc7
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
GEN3 FG (fuel gauge) is a new hardware peripheral which cannot
be supported along with existing GEN1/GEN2 FG supported under
qpnp-fg.c. Some of the differences are listed below.
- No conventional memory access for accessing SRAM
- No OTP region for battery profile
- FTRIM registers will be loaded to SRAM
- SRAM partitioning and address format got changed completely
- Battery id detection done by RR_ADC
- Encoding/Decoding changes for battery parameters
Hence add a new driver to support this GEN3 FG. This driver
reads the battery parameters like voltage, current, temperature,
resistance etc. acquired by the FG hardware and expose to the
userspace through a power supply class device.
Change-Id: Ibcd6e49c7dc7c3520527bcf9553296e846fb7458
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Currently power supply name is passed to get the battery profile
in of_batterydata_get_best_profile(). This creates a dependency
of waiting for the driver that has the power supply class device.
Improve this by passing the battery id directly to the API. This
way, getting battery id will be the responsibility of caller.
CRs-Fixed: 1043798
Change-Id: I7a8c2b2fcc9b43e2e858114f7312fccf96dc3f78
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>