msm: video: wfd: Add error handling while wfd open.

- Error handling is not performed when memory allocation failed.
- Reset wfd driver status to false.

Change-Id: Iaa06d54e987f2f3ad8c3d9f657b64a11f4308df4
CRs-Fixed: 383712
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Revert "Revert "The error checking is not performed when the clocks are enabled.""

This reverts commit a9f1ac687aa409716d1be8bd5865d25b6f443db1.
Revert "Revert "mmc: msm_sdcc: Fix deadlock while resuming sdcc from userspace""

This reverts commit acbccd7eb2610c362ff606c690d937caf8351bbe.
Revert "Revert "mmc: msm_sdcc: Revert to the older clock-APIs""

This reverts commit 0b850e1dee2dad0f6133e76af1f66f7f9c5e4549.
mmc: msm_sdcc: Print data line status in case of errors

The MCI_TEST_INPUT register of the SDC controller depicts the status
of the data lines (if pulled down or not). Print its state in cases of
errors to isolate any device specific issues.

CRs-Fixed: 392889
Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org>
(cherry picked from commit 74bff7cf272ebebc04de8e99a216c32519df52fa)

Conflicts:

	drivers/mmc/host/msm_sdcc.c

Change-Id: I1298eb8242b0f10bc5d80adce5c05ccfe70b7984
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: vidc: Enable turbo mode based on client request.

- video core is bumped up to turbo mode, if more performance
  level required from multiple clients.

- Enable turbo mode atleast one of client set turbo mode.

CRs-Fixed: 385454
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
(cherry picked from commit 1356b5826e2f9c75ac3feef61ff31fa272a97232)

Conflicts:

	drivers/video/msm/vidc/common/vcd/vcd_core.h

Change-Id: I114f41b3f1166fbc707ae598d61f63326bf6427f
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: usb: Tune USB PHY squelch threshold settings

Currently, USB PHY squelch threshold settings(SQRXTUNE) is having
the power on reset value(0x3), due to which enumeration failures
are observed, if amplitude of the USB signal received is less than
threshold. Fix this issue by updating the SQRXTUNE value using
OVERRIDE B register from 6 to 3.

CRs-Fixed: 386598
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
(cherry picked from commit f983aebfe0b774a22a31b8f75d8d13347b6b25a5)

Conflicts:

	arch/arm/mach-msm/board-8064.c
	arch/arm/mach-msm/board-8930.c
	arch/arm/mach-msm/board-8960.c
	arch/arm/mach-msm/board-9615.c

Change-Id: I3b56cd7d87d1cbb53300fe07e3b6a29e03b18f87
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: gpio-v2: Dont re-enable the interrupt and clear the status

If a gpio interrupt is already enabled, do not re-enable it again
and do not clear the interrupt status.
Before this patch:
If an edge interrupt is marked as wakeup, the gpio sys suspend will
clear the status and enable it.
On Resume - the gpio sys resume would clear the intr_status of the wakeup
irq.
Thus, if this particular wakeup irq triggered and woke us up, we lose its
intr_status before calling the gpio summary handler.
Now, when the summary handler is finally called, the irq handler for the
wakeup interrupt is never called.

With this change:
1) Not clearing the intr_status on sys-resume, ensures that it is marked as
pending in the gpio layer.
2) Not re-enabling it again, makes sure that when the irq framework unmasks
all irqs on resume, it does not clear the intr_status either.

Change-Id: I7289522c8c9c97c6f4210433814013160678d130
CRs-Fixed: 400562
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
msm_fb: display: Add timeout for waiting on update

Content Adaptive BackLight userspace algo waits on UPDATE_NOTIFY to
get the screen updates. When turning off CABL, this blocking ioctl
causes the CABL threads to wait until next screen update, which may
take indefinite time.

Add timeout value to the wait_for_completion call, to make ioctl
call blocking for at most timeout value.

CRs-Fixed: 384026
Signed-off-by: Kinjal Bhavsar <kbhavsar@codeaurora.org>
(cherry picked from commit 1b6843a3a56e60e73305c66369f8ad806353e22d)

Change-Id: Ie550f650f399ec15eaedb3814aac6a8562b5bd46
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
power: pm8921-charger: Fix liquid 8960 charging LEDs report

LiQUID orange charging LED should be immediately on/off
after external charger start/stop charging (i.e. DC insert/remove).
The green charging LED is on after End-Of-Charging detected.
The blue LED should be used for message notification
and not for dc-online report.

Change-Id: Id53829072ab213c3e594a539c57372bc9db3d340
Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
msm: 8960: Make connector resistance value consistent

The BMS and charger platform data do not reflect
consistent connector resistance.

Fix this by using the rconn_mohm value from the
charger platform data which was the measured value, rather
than the BMS value which was picked for debug purposes.

Change-Id: I50c8a3bc672cc1d62e75d04707bb90342946b17c
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-bms: fine tune the uuc scaling algorithm

For every soc calculations there are three unusable charge (uuc)
values.
uuc_uah_itest:
	The uuc value in micro amp hour (uah) based on the max current
	(itest). Typically this value is very high and changes as the
	battery resistance changes
uuc_uah_iavg:
	The uuc value based on the average current (iavg). Typically
	this is lower than uuc_itest
uuc_reported:
	The reported uuc based on state of charge (SOC) of the battery
	which chooses a stepsize value and approaches towards
	uuc_uah_itest or uuc_uah_iavg based on whether the device is
	being charged.

The expectation is that the reported uuc increase as the battery looses SOC
and decrease as SOC approaches full condition.

To help us coming up with a satisfactory algorithm the following
parameters are introduced.
uuc_multiplier:
	The multiplier used in stepsize calculation
uuc_iavg_div:
	The divisor to use in calculation of stepsize when there
	is a significant jump in average current from the
	previous attempt
uuc_min_step_size:
	The minimum stepsize to use if the calculated stepsize is very less

Also, in order to ignore the high bootup time load a timer is introduced
which makes the algorithm ignore iavg values upon bootup.

The algorithm also uses the previous uuc based on iavg in
"uuc_uah_iavg_prev". This aids in checking if there was a significant
increase in average current from the previous time uuc was calculated.
The algorithm keeps track of the previous reported uuc in last_uuc_uah.

Change-Id: I360fd74e7fd2c939dd67023c128b2d70da923e9a
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-charger: change BOOT_DONE configuration

Set the BOOT_TIMER_EN bit when writing the
BOOT_DONE configuration. This is required to make
sure the boot timer will be enabled during the
next phone boot.

Change-Id: I0c43de3a0c285979f7bccd42e464ca0d2fbbe42a
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-charger: add UVD threshold API

PM8917 has a new register which allows configuring
the falling USB under voltage detection (UVD) threshold
from 3.85V to 4.35V in 100 mV steps.

Add an API that allows to set this value per default and
also only do this for PM8917 chips.

Change-Id: I9b4259b43f148762ac72af40bdc79b895d9b4fc2
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-charger: add reverse boost fix for dc_in

Reverse boosting is also seen on the DC charging path
and may cause charger removal detection problems.

Fix this by changing the reverse boost detection to only
check the active charging path. Only the active charging
path will see reverse boosting voltages because the other
path's OVP will automatically be opened (off) by the
hardware.

Change-Id: I23a48cd49d912e2bb2651159ec91d0ccfa7f5e0d
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-charger: add dc_unplug_check option

Add a configuration option to enable or disable
the reverse boost fix for the DC charging path.

Some board designs do not utilize the DC_IN path
on the PMIC, however they do use the presence
detection of DC_IN to enable the auto switching
and interrupt features. In these particular configurations
the PMIC does not control the DC OVP FETs.
Hence add an option to enable or disable the DC path workaround
and leave the workaround disabled by default.

Change-Id: I1e55bbfe37c7cc6f62581af11280a565ed648c06
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: power_supply_core: add power_supply_set_supply_type API

Allow other drivers to change the supply type of a given power
supply. This is required when a USB driver determines the exact
USB connection type and needs to notify the owner of the usb power
supply struct.

Change-Id: I99d377628a296704e1dcd170251ab9ceadc653ec
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-bms: dont use override mode if batfet is open

If the battery fet is open, the current sourced or sinked from the
battery is very low. There is a high chance that an open circuit
voltage(OCV) happens. Putting the BMS in override mode resets the timer
whose expiry causes an OCV.

Avoid putting the BMS in override mode if battery fet is open.

Change-Id: Idc463bcc55b51cf188cc8ee440a66f763654f174
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: remove reading rbatt from bms

Since battery resistance is found to be changing w.r.t. state of charge,
temperature and time since a load change happened, it is best if rbatt
is estimated using learnt tables.

Remove all the code that attempts to read battery resistance from BMS.

Change-Id: Id8d84d610df0bcca79d7e42ffae572c0898d63c6
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
power: pm8921-bms: fix rounding down state of charge

The code is rounding down state of charge value in the final step of the
calculation. Instead use a division that returns the closest integer.

Change-Id: Ia47d1c4eb684dd4c31e454dc762add0feab66b75
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>