msm: mdss: Do not override ARGC setting on LM

Layer mixer configuration overrides the ARGC
setting when it updates the blend color settings.
This removes the ARGC setting configured by post
processing module and calibration tool in tuning mode.
This change reads the ARGC setting and applies
it back during blend color setting.

Change-Id: I72612ad428e58a1e343e94ab965137628bcce661
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
msm: camera: sensor: Update to use wait_for_completion.

Use wait_for_completion in place of wait_for_completion_interruptible

Change-Id: I960b334128e2b811b27c64721a65f7c7e773b085
Signed-off-by: Rajesh Bondugula <rajeshb@codeaurora.org>
qpnp-rtc: clear alarm register when rtc irq is disabled

The rtc alarm register should be cleared when the rtc irq is
disabled

Change-Id: I97a8bf989ff610093240a6b308a297702da6cb89
Signed-off-by: Xiaocheng Li <lix@codeaurora.org>
msm: mdss: disable irq to enforce mutex within dsi_event_thread

Mdp spin lock is used in dsi_event_thread and in irq context.
Disable irq while holding spinlock to avoid context switching
into irq context and cause spinlock recursion

CRs-fixed: 652850
Change-Id: I4bd8cadb1f5d83acc7e866344b7585e7944e08ac
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: kgsl: Take the pagetable reference count only when needed

There could be a race condition where one thread is iterating
over ptlist inside kgsl_get_pagetable() with spinlock acquired
and going to call kref_put(). At the same time another thread is
inside kgsl_put_pagetable() without any spinlock calls kref_put()
and returns without calling kgsl_destroy_pagetable(). The decrement
of refcount by second thread leads to a situation where first thread
enters kgsl_destroy_pagetable_locked() and hence destroying the pt
node from list. This causes the destroyed pt node's next and prev
pointers set to POISON value resulting in kernel panic while executing
next iteration of ptlist.

Taking pt refcount while iterating over ptlist should be avoided if the
spinlock is already held and the pt is not returned to the caller. In
kgsl_get_pagetable(), since the loop is already holding the mutex, it
is safe to look at pt before taking a reference.

CRs-Fixed: 661374
Change-Id: Ide1f57cc1eb3cbf66fa399b6b72491755b999c7a
Signed-off-by: Prabhat Awasthi <pawasthi@codeaurora.org>
msm: qpnp-power-on: print the power off reason

The PMIC power off reason is often very useful for debugging. By
printing the power off reason, testers can tell whether a shutdown
was a normal controlled shutdown by the MSM or a unexpected PMIC
shutdown.

Add a single log message per PMIC to print out the power off reason
and a short explanation of the likely cause.

Change-Id: I438e5915f6ac7372af6e39e5dff7a3709623b763
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
cfg80211: avoid restoring the regulatory during disconnect

Driver configures the default country code during bootup.
When STA disconnects,cfg80211 restore the regulatory setting
to world domain.cfg80211 should remain in the default country
code and not restore to world reg domain.

Change-Id: I01ccdc4d2831cf252a4b35f9f856f3256d9b7429
CRs-Fixed: 630014
Signed-off-by: Sachin Ahuja <sahuja@codeaurora.org>
qseecom: change return value to 0 if app id exists when loading app

Currently qseecom will return the app_id (>0) instead of 0 if the
app id already exists when loading app. Then the userspace client
will release qseecom handle if an non-zero return value is obtained.
Make a change to let qseecom return 0 when app id exist so as to
avoid the incorrect qseecom release.

Change-Id: I03b0b0ae95b2e043fda972aa3b613e7df585154a
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
qseecom: Add support to handle multiple app load & unload

Media server is associated with multiple apps on TZ-side.
Unloading a single app for clean up is not enought. QSEECOM
needs to handle the app load & unload of multiple apps
associated with the client. During app_load & app_unload
along with app_id, app_name should also be checked. Besides,
keymaster will not be unloaded and app search execution
during app unload is optimized.

Change-Id: Ie92e97b9154851b713a8c3394b8ed10fdbdebd2f
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Merge "qseecom: Add support to handle multiple app load & unload"
clock-8974: Support the USB UTMI clock source divider

The gcc_usb30_mock_utmi_clk also contains a CDIV divider
that can do integer division on 8974V2 and newer targets.
Support this divider in clock-gcc-8974.
Drivers will need to set a rate on usb30_utmi_clk_src, and
then set a divider on gcc_usb30_mock_utmi_clk. Both of these
operations shall make use of the clk_set_rate API.
Also update the frequency table on usb30_utmi_clk_src to
include a new 48MHz rate.

Change-Id: I0952fc25b187456eeb98b8bc4a3c5d51fd10a67a
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
usb: dwc3: Enable newer refclk-based SOF/ITP generation

Add support for refclk-based SOF and ITP generation, which is
present on DWC3 cores starting in revision 2.50a. This supersedes
the functionality provided by GCTL.SOFTITPSYNC which handled ITP
generation only. This introduces the new GFLADJ register and
writes its fields based on the reference clock period to the
core, which can now be specified as a device tree parameter.

Change-Id: I2c57586cd8b5275b77ebe64cf0835617f0340b62
Signed-off-by: Jack Pham <jackp@codeaurora.org>
USB: dwc3-msm: Add support for 24MHz utmi clock

For ref clk based SOF/ITP generation, utmi clock needs to be set
to frequencies like 19.2MHz, 24MHz etc. Hence add support for
setting utmi clock to 24MHz.

Change-Id: Ia64eaa5320846ab219c516f43e6dcdf0fb05eb89
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
ARM/dts: Set ref clock to 24MHz for msm8974

Set ref clock rate to 24MHz for 8974 platform for ref clock
based SOF/ITP generation. Otherwise enumeration of peripherals
will fail.

Change-Id: I8425e82f5ceaf3a8bcb4a5d1a3ccc7954e44d752
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
Merge "Merge "qseecom: Add support to handle multiple app load & unload""
msm: mdss: control backlight level during blank and unblank events

Add code to set the backlight level to zero for blank event
and restore the backlight level to its previous value during
unblank event. This will fix any unexpected panel flicker
that might show up on the screen during panel ON sequence.

CRs-Fixed: 649073
Change-Id: I871a067b0cc40d893b8b7e5a25103ebb914f9b7a
Signed-off-by: Chandan Uddaraju <chandanu@codeaurora.org>
Signed-off-by: Benet Clark <benetc@codeaurora.org>
mmc: core: enhance card removal judgement for slow removal

Function _mmc_detect_card_removed will be called to know whether
the card is still present when host->bus_ops->detect is called.
In current code, the return value of this function generally only
depend on the result of sending cmd13 to card, which may not safe
for card with detection support like slot gpio detection.
Because the communication status between host and card may out of
sync with the detect status if remove the card slowly or hands shake
during the process. The direct reason is the async between card
detect switch and card/slot pad contaction in hardware, which is
defined by spec.

The spec define card insert/remove sequence as below (both standard size
SD card and MicroSD card have the same sequence):
"Part 1 Standard Size SD Card Mechanical Addendum Ver4.00 Final,
Appendix C: Card Detection Switch" (Take normally open type as example)
a)SD card insertion sequence:
  The card detection switch should be turned on after all SD card
  contact pads are connected to the host connector contact pads.
b)SD removal sequence:
  The card detection switch should be turned off when the SD card
  is just going to be removed and before any SD card contact pad is
  disconnected from the host connector contact pad.

Below is the sequence when this issue occur (Take slot gpio detection
as example and remove the card slowly during the process):
1. gpio level changed and card detect interrupt triggered.
2. mmc_rescan was launched.
3. the card pads were still contacted with the slot pads because of slow
   removal. So _mmc_detect_card_removed and mmc_rescan think card was
   still present (cmd13 succeed).
4. card pads were discontacted from the card slot pads.
So the card was actually removed finally but the card removal event
has been missed by system.
The interval length between step 1 and step 4 depends on the
card removal speed. If it's longer than the detect work schedule
delay which is 200ms, this issue will likely happen.

This patch add the card detect status check in function
_mmc_detect_card_removed if cmd13 check succeed and host->ops->get_cd
provided. If get_cd detect no card present then schedule another detect
work 200ms later.

CRs-fixed: 655754
Change-Id: I167309242c9937b023d14797177deb0e6be8838d
Signed-off-by: Kevin Liu <kliu5@marvell.com>
Git-commit: 1450734ec61cda7bbb77afc8cb412b9d64c62d9a
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc.git
Tested-by: Johan Rudholm <johan.rudholm@stericsson.com>
Reviewed-by: Philip Rakity <prakity@nvidia.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
mmc: core: invoke low power mode if card is not present

If get_cd is defined and card is not present mmc_rescan
returns without invoking mmc_power_off. This would prevent
low-power modes.
Hence, invoke mmc_power_off if card is not present before
exiting mmc_rescan.

CRs-fixed: 655754
Change-Id: Id148fdf48e7f112da1251f8b60ac5d4c89a89e9f
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Merge "msm: camera: sensor: Update to use wait_for_completion."
Merge "msm: qpnp-power-on: print the power off reason"