Commit graph

592291 commits

Author SHA1 Message Date
Nicholas Troast
96168e19d4 power: qpnp-fg-gen3: make TTF monotonic by limiting slope
Currently if there is a spike in system load or a thermal event which
causes the battery current to change dramatically then the TTF can jump.

While a battery is charging the TTF should be monotonically decreasing.

Track the TTF starting with the first estimate and set hard bounds of -2
and -0.1 on the slope. The negative slope ensures the TTF is
monotonically decreasing and the hard bounds on the slope smooth out
significant changes in the TTF.

Change-Id: I68a934599ff25bc5a9eb67b372b28a723532a540
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-08-04 11:17:03 -07:00
Nicholas Troast
811a8bd2ef power: qpnp-fg-gen3: optimize TTF for QNOVO
QNOVO provides a table of expected charge current settings across the
charge cycle. Use this table to calculate the time it will take to
charge in each step. The sum of these steps is the total time it will
take to fully charge a battery.

Change-Id: I0ed48a2a63886531e761e7ce1d175a600060eaf8
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-08-04 11:17:02 -07:00
Nicholas Troast
e55198f9ef power: qpnp-fg-gen3: prepare for QNOVO TTF
Micro resolution and 64-bit division is unnecessary; use milli
resolution instead. Measuring the IBATT and VBATT periodically during
sleep is necessary for accuracy. Don't clear the IBATT and VBATT buffers
on suspend to account for the higher charge current during suspend.
Prime the IBATT and VBATT buffers with 10 samples to get a more accurate
first estimate. Introduce a ttf mode to separate the differences in the
QNOVO version of TTF.

Change-Id: Ibc591dd5d38d4bbb712d8906755040d59181f008
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-08-04 11:16:53 -07:00
Nicholas Troast
175907d3d2 power: fg-util: add median filter for circular buffer
A median filter is useful for filtering out outliers. Add it.

Change-Id: I21f97a870c262e5fb3d33b8250a2bf074f519b58
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-07-31 19:28:02 -07:00
Abhijeet Dharmapurikar
3c21390e3c power: qpnp-fg-gen3: use the CC_STEP and CC_STEP_SEL properties
Add support for the CC_STEP and CC_STEP_SEL properties in the BMS power
supply. These properties will be used to communicate the future charge
currents for time to full calculations.

Change-Id: I44087b42b31800d1885bdaf1f38815c8756bc9a8
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-07-31 19:28:02 -07:00
Nicholas Troast
eb8700f685 power_supply: add CC_STEP and CC_STEP_SEL properties
There are several algorithms which modify the charge current in steps
across the charge cycle. CC_STEP is used to notify of all the upcoming
charge currents.

The CC_STEP_SEL property is used to select the index of the CC_STEP to
read or modify using the CC_STEP property.

Change-Id: Ieeb533b758035c1c408cdfd68f001374bf0987a5
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-07-31 19:28:01 -07:00
Abhijeet Dharmapurikar
3fcbb078c8 qpnp-smb2: Ignore status 7 register while qnovo is enabled
status7 register will indicate all the charger bits are cleared during
the rest or discharge phase of a Qnovo pulse. Moreover those bits remain
cleared after a pulse train is done and before a new pulse train is
issued.

Hence when Qnovo is active ignore status 7 register bits.

Change-Id: Ice61f8a49625081ffbf1aacaac844b929715e818
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-07-31 19:28:01 -07:00
Harry Yang
2aced65bf8 qcom: qnovo: restart pulse train in stall state
There are a couple of cases where qnovo charging fails,

1. pulse train enable command register fails to write through, or
2. pulse engine fails to start and pulse train timer PTTIME does
   not start counting.

In either case, qnovo charging will stop. Here is the fix,

Write register twice when enabling pulse train, and
restart pulse train if PTTIME does not increase.

Change-Id: Ic235f8f2bc67fe577e42848ef623870c25b68256
Signed-off-by: Harry Yang <harryy@codeaurora.org>
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-07-31 19:28:00 -07:00
Abhijeet Dharmapurikar
cbff20cc9a qpnp-qnovo: add debounce for charger
The request is to delay ok_to_qnovo for 15 seconds after a charger is
inserted.

To achive that:
Make ok_to_qnovo variable as a votable that can be voted on by
A. HW error conditions
B. Charger is ready  after debounce

Moreover since there could be two chargers -usb and dc, create another
votable to track their individual debounce states. The result of this
votable will feed in to ok_to_qnovo votable as branch B above.

Also since we need to stay awake for the debounce time, create an
awake_votable and vote on it while debounce on either usb or dc is in
progress.

Change-Id: I32dc07ba16ef0515a9683f2702d317c39baa2eba
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-07-31 19:28:00 -07:00
Abhijeet Dharmapurikar
354e7f16bd qpnp-qnovo: prevent pulse train while esr is in progress
At the end of pulse train ESR measurement is forced. It is expected
that when ESR is being measured, which takes about 1.5 seconds, the
next pulse train does not start.

However we see that a uevent is sent to userspace and it enables pulse
train within 100mS.

To prevent that put the pulse train enabling bit under a votable
control. And make QNI_VOTER (the userspace voter) and ESR_VOTER vote
on it.

Moreover, the current pulse train enabling path checks if qnovo was
enabled, make a QNOVO_OVERALL_ENABLE voter to this new voter to reflect
it.

Change-Id: I6d2177250cc47f5aeb6591c532ee18d37e3b02c6
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-07-31 19:27:56 -07:00
Abhijeet Dharmapurikar
18cb81a94f qpnp-fg-gen3: qnovo ESR/IADC workarounds
When FG IADC measurement period coincides with qnovo discharge pulses
it reads incorrect IADC values. That causes issues with SOC accuracy
and capacity learning amongst others.

The fix to IADC inaccuracy is to set a bit in the FG
peripheral while Qnovo is active.

A side effect of IADC inaccuracy fix is that the ESR
measurement goes haywire. To overcome that, disable ESR when
Qnovo is active and force an esr measurement when its between pulses.

Realize this by disabling ESR and enabling the bit when
Qnovo becomes active. The qnovo driver will set CHARGE_QNOVO_ENABLE
property on the bms psy when its active. Also provide code to
force an ESR measurement via a write to RESISTANCE property in
bms psy.

Change-Id: I7160ad6288362c17d28d67b38ec09332d9a6cbd2
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-07-31 19:26:29 -07:00
Abhijeet Dharmapurikar
7b5b0b5914 qpnp-qnovo: IADC/ESR workarounds
When FG IADC measurement period coincides with qnovo discharge pulses
it reads incorrect IADC values. That causes issues with SOC accuracy
and capacity learning amongst others.

The fix to IADC inaccuracy is to set a bit in the FG peripheral while
Qnovo is active.

A side effect of IADC inaccuracy fix is that the ESR measurement goes
haywire. To overcome that, disable ESR when Qnovo is active and force
an esr measurement when its between pulses.

Realize this by setting CHARGE_QNOVO_ENABLE and RESISTANCE property on
the bms psy at appropriate times in the driver.

Change-Id: I5b37083c843ec6bc052c4d344347b9a80554e226
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-07-31 19:23:19 -07:00
Linux Build Service Account
a6e2c2983f Merge "msm: mdss: do not update polarity for DSI interface" 2017-07-28 08:21:45 -07:00
Linux Build Service Account
8198f75d01 Merge "rwsem: fix missed wakeup due to reordering of load" 2017-07-28 08:21:44 -07:00
Linux Build Service Account
7aaa3c344e Merge "msm: mdss: Fix race condition during mdp dump" 2017-07-28 08:21:43 -07:00
Linux Build Service Account
e58ec92ae4 Merge "msm: mdss: Remove check to cap requested mdp clock" 2017-07-28 08:21:42 -07:00
Linux Build Service Account
e81d17ff12 Merge "msm: kgsl: Fix the syncpoint_fence trace" 2017-07-28 08:21:41 -07:00
Linux Build Service Account
deea343b37 Merge "msm: ADSPRPC: Handle SMD event signal" 2017-07-28 08:21:40 -07:00
Linux Build Service Account
f687374863 Merge "mhi: uci: Fix a bug related to split transfer packets" 2017-07-28 00:21:21 -07:00
Linux Build Service Account
8233df121f Merge "diag: Flush control workqueue immediately on channel close" 2017-07-28 00:21:12 -07:00
Linux Build Service Account
96e98ab9bb Merge "diag: Free the read workqueue structure to avoid memory leak" 2017-07-28 00:21:11 -07:00
Linux Build Service Account
1036b05d5c Merge "ARM: dts: msm: Make allocation for diag as guaranteed on sdm630" 2017-07-28 00:21:11 -07:00
Linux Build Service Account
88d5f45f9b Merge "power: smb-lib: Update the FLOAT detection logic" 2017-07-28 00:21:10 -07:00
Linux Build Service Account
769a4cebb1 Merge "ath10k: Fix dst CE ring configuration for CE5" 2017-07-28 00:21:09 -07:00
Linux Build Service Account
954d1c4aae Merge "msm: ipa3: add offline charging support" 2017-07-28 00:21:08 -07:00
Linux Build Service Account
a544e587d3 Merge "msm: sde: fix kernel booting failure in sde driver" 2017-07-28 00:21:07 -07:00
Linux Build Service Account
77c2b121e2 Merge "msm: sensor: Fix for variable being de-referenced without proper check" 2017-07-28 00:21:06 -07:00
Linux Build Service Account
a89a16f8e3 Merge "msm: camera: Add support for TOF sensor on msm8998 QVR" 2017-07-28 00:21:05 -07:00
Linux Build Service Account
1680902b96 Merge "ath10k: fix memory leak in rx ring buffer allocation" 2017-07-28 00:21:04 -07:00
Sujeev Dias
17aec3c9ff mhi: uci: Fix a bug related to split transfer packets
When transfer buffer is larger than available space, uci driver will
split the transfer into multiple transactions. Driver incorrectly
calculated the transfer length and caused infinite transfer.
Simplify uci write method to avoid such bugs.

CRs-Fixed: 2083693
Change-Id: Ic7169cefda6a4637511ecfa3ce5ddde6f3d55f8c
Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
2017-07-27 12:54:08 -07:00
Linux Build Service Account
ac8211566b Merge "msm: ispif: fix the OOB read issue" 2017-07-27 06:47:06 -07:00
Linux Build Service Account
08a5bd86c1 Merge "wcnss: fix the potential buffer flow issue in firmware setup" 2017-07-27 06:47:05 -07:00
Prateek Sood
c2878c131a rwsem: fix missed wakeup due to reordering of load
If a spinner is present, there is a chance that the load of
rwsem_has_spinner() in rwsem_wake() can be reordered with
respect to decrement of rwsem count in __up_write() leading
to wakeup being missed.

 spinning writer                  up_write caller
 ---------------                  -----------------------
 [S] osq_unlock()                 [L] osq
  spin_lock(wait_lock)
  sem->count=0xFFFFFFFF00000001
            +0xFFFFFFFF00000000
  count=sem->count
  MB
                                   sem->count=0xFFFFFFFE00000001
                                             -0xFFFFFFFF00000001
                                   RMB
                                   spin_trylock(wait_lock)
                                   return
 rwsem_try_write_lock(count)
 spin_unlock(wait_lock)
 schedule()

Reordering of atomic_long_sub_return_release() in __up_write()
and rwsem_has_spinner() in rwsem_wake() can cause missing of
wakeup in up_write() context. In spinning writer, sem->count
and local variable count is 0XFFFFFFFE00000001. It would result
in rwsem_try_write_lock() failing to acquire rwsem and spinning
writer going to sleep in rwsem_down_write_failed().

The smp_rmb() will make sure that the spinner state is
consulted after sem->count is updated in up_write context.

Change-Id: I96de9a65adedb35d1ee2c6c36dc7759c9b8f5d4d
Signed-off-by: Prateek Sood <prsood@codeaurora.org>
2017-07-27 04:58:44 -07:00
Manoj Prabhu B
d276e8814c diag: Free the read workqueue structure to avoid memory leak
The patch frees the read workqueue structure after
scheduled workqueue processes the glink buffers and notifies
glink to avoid possible memory leak.

CRs-Fixed: 2083447
Change-Id: I4e562f9d1cbf02d8306e0a127835af85dfa5db23
Signed-off-by: Manoj Prabhu B <bmanoj@codeaurora.org>
2017-07-27 15:27:23 +05:30
Mohit Aggarwal
bf74f23874 diag: Flush control workqueue immediately on channel close
Currently, flushing of control workqueue is happening
under protection which is causing a deadlock. The patch
fixes the issue by flushing the control workqueue on
immediate closure of channel.

CRs-Fixed: 2081948
Change-Id: I6a7b1ee7cbabf2974700e28fc62c6d8fa3d464ed
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
2017-07-27 14:10:04 +05:30
Mohit Aggarwal
cf6a289518 ARM: dts: msm: Make allocation for diag as guaranteed on sdm630
Currently, memshare allocates 5MB memory to diag client on
receiving requests from modem. With the patch diag client
will be considered guaranteed on sdm630 to avoid memory
allocation failure on modem SSRs. Also being guaranteed
client allocated memory will never be freed.

CRs-Fixed: 2054448
Change-Id: I7b0780d064a27e8ebca9d31747ce1f9c18d84fdb
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
2017-07-27 13:43:36 +05:30
Linux Build Service Account
0a57938d14 Merge "cnss2: Print string for firmware mode" 2017-07-26 19:22:55 -07:00
Linux Build Service Account
15d76668b0 Merge "icnss: Set crash state for PDR" 2017-07-26 19:22:54 -07:00
Linux Build Service Account
0bce290a42 Merge "hotplug cpu: ratelimit logs for thermal veto" 2017-07-26 19:22:53 -07:00
Linux Build Service Account
827f654338 Merge "msm: ipa3: disable clock gating for MISC" 2017-07-26 19:22:44 -07:00
Skylar Chang
00f9f948b0 msm: ipa3: add offline charging support
In offline charging mode, modem is not loaded so the proxy
IPA clock vote added by IPA driver on behalf of modem is
never released and this prolongs the charge time. Move the
proxy vote to IPA3_POST_INIT before rmnet_ipa driver init
completes.

Change-Id: I271c8e6916d0c3068f720ae81b67f0fc5c198b6f
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
2017-07-26 16:27:19 -07:00
Yue Ma
0e8dffdaf8 cnss2: Print string for firmware mode
This can clearly show the firmware mode sent through QMI message
in the logs to help debugging.

Signed-off-by: Yue Ma <yuem@codeaurora.org>
CRs-fixed: 2059087
Change-Id: I0b11808f00229ed557141226bc2510673a7a1ede
2017-07-26 10:51:59 -07:00
Anirudh Ghayal
3abd7de15e power: smb-lib: Update the FLOAT detection logic
An SDP may get detected as a FLOAT charger by PMIC APSD.
To handle this case do the following steps when a FLOAT
charger is detected -

1. Limit the ICL to 100mA and start USB enumeration
2. If enumeration succeeds, USB notifies a valid
   ICL and the charger updates ICL and charger-type to SDP.
3. If enumeration fails, USB notifies -ETIMEDOUT and
   charger applies ICL based on the Rp value.

CRs-Fixed: 2081457
Change-Id: I2747a42ed9f9531e83c53d781a8ae9baa9aa74d0
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
2017-07-26 22:52:45 +05:30
Linux Build Service Account
1c9a156e41 Merge "ARM: dts: msm: enable DP functionality for SDA660 HDK platform" 2017-07-26 08:44:58 -07:00
Linux Build Service Account
e6cb8897ab Merge "msm: camera: Make use of mutex lock to avoid race condition" 2017-07-26 08:44:55 -07:00
Linux Build Service Account
bc72999165 Merge "msm: ais: sensor: validating the flash initialization parameters" 2017-07-26 08:44:54 -07:00
Linux Build Service Account
2991c52124 Merge "icnss: Consolidate logging message" 2017-07-26 08:44:53 -07:00
Linux Build Service Account
74d929874d Merge "drm/msm: Turn off hardware clock gating before reading A5XX registers" 2017-07-26 08:44:51 -07:00
Linux Build Service Account
123ada77d0 Merge "ARM: dts: msm: Add qseecom device node on msm8996 lfv platform" 2017-07-26 08:44:50 -07:00
Linux Build Service Account
67edc020df Merge "misc: qseecom: Support qseecom deferred probing" 2017-07-26 08:44:49 -07:00