mfd: wcd9xxx-core: fix the device registeration check.

The current logic checks for only one byte id for device
registration. this is not sufficient to identify all
variants. fix this to check all 4 byte id registers.

Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
(cherry picked from commit fbe371bbce2b166e4f651454f00fe4e8ecc2c3b8)

Change-Id: Ife41b16049f9061fc649ad78ed887681c85f5ac1
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: clock-8960: Add core clock for second gfx3d iommu on 8960ab.

The 8960ab has two gfx3d iommus one of which was missing.
Also add a dependency on gfx3d_axi_clk for 8960ab.

Signed-off-by: Joel King <joelking@codeaurora.org>
(cherry picked from commit 9af070bb08217aa3668be5a1ff7ab3cc7964c64c)

Change-Id: Ic45910df027a02766a1841b825c16ea7413d65ca
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: rpm-smd: Fix error codes returned by msm_rpm_wait_for_ack

Fix msm_rpm_wait_for_ack API to return a -ENOMEM when a message id 0 is
passed in. The patch also reserves the message id 1 for cases when the
send message doesn't send duplicate data. This ensures that wait for ack
doesn't return a error code for this scenario.

Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
(cherry picked from commit 7ef2aadfe25e756b855861b81a9f21d324a59585)

Change-Id: I7b87fab077b04f76db99eb4446e1526b259950b4
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: scm-boot: Clarify types for scm_set_boot_addr()

The boot address is a physical address (even if the secure
monitor only considers it to be 32 bits). Move to using
phys_addr_t to clarify this is a physical address and to ease
any support of LPAE in the future. Also make the flags unsigned
so that we can use the highest bit if necessary.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit efadd5b002a819d0e0213ac10a1e3d1c9463a07b)

Change-Id: I06c5af4093b6fa947a8705364425de2c54464cde
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
jtag: restore only if save has occurred

When power collapse is disabled, hotplug OFF of non-boot
core will result in WFI and hence msm_jtag_save_state
will not occur. Subsequently, during hotplug ON of
non-boot core when msm_jtag_restore_state is called via
msm_platform_secondary_init, we will now bail out without
restoring to help retain sane value of the restore counter
and prevent register restoration.

Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
(cherry picked from commit 3a64a0f54fdaf07baf15cacf869600a125538101)

Change-Id: I8f6fc5b0601c7b696bb5ba53ef724abb1a99a1ed
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
mmc: msm_sdcc: fix race conditions in runtime PM

What is the race condition? (NOTE: RPM stands for Runtime Power Management)

1. SDCC is in RPM_SUSPENEDED state and SDCC platform suspend gets
   triggered and then system goes into suspend.
2. During platform resume, SDCC platform resume is triggered
   which blindly sets the pending_resume flag in SDCC host structure.
3. If new MMC transfer request comes then MMC block driver calls
   mmc_claim_host() which internally calls msmsdcc_enable().
4. msmsdcc_enable() checks for following 3 conditions to be true:
	1. host->sdcc_suspended == true
	2. host->pending_resume == true
	3. pm_runtime_suspended() == false
   But as SDCC state is RPM_SUSPENDED, 3rd condition is not be satisfied
   so msmsdcc_enable() don't clear the host->pending_resume flag and simply
   calls pm_runtime_get_sync() to resume the SDCC. Once SDCC is resumed,
   host->sdcc_suspended = false, runtime_status = RPM_ACTIVE but
   host->pending_resume is still set.
5. Now after RPM idle timeout, SDCC runtime suspend gets triggered which
   calls SDCC driver's runtime suspend callback (msmsdcc_runtime_suspend).
   Note that before executing the RPM suspend calllback, SDCC RPM status
   is set to RPM_SUSPENDING.
6. As SDCC driver's runtime suspend callback gets executed, it sets the
   host->sdcc_suspended to true. But now before the RPM framework
   sets the SDCC RPM status to RPM_SUSPENDED, on other active CPU core,
   new MMC transfer reques comes in which would first call msmsdcc_enable()
   and all of the 3 conditions below is true:
	1. host->sdcc_suspended == true
	2. host->pending_resume == true
	3. pm_runtime_suspended() == false (RPM status is RPM_SUSPENDING)

   As these conditions are satisfied, msmsdcc_enable() does not call
   pm_runtime_get_sync(), instead just calls pm_runtime_get_noresume() and
   msmsdcc_runtime_resume(). This means even after execution of
   msmsdcc_enable(), SDCC RPM status is either RPM_SUSPENDING or
   RPM_SUSPENDED.
7. RPM suspend framework on 1st core sets the SDCC RPM status to
   RPM_SUSPENDED once SDCC runtime suspend callback returns.
8. Now once MMC transfer request is completed on other core, it will call
   msmsdcc_disable(). This function calls pm_runtime_put_sync() which
   returns -EAGAIN error as RPM status is already RPM_SUSPENED.
   This error gets returned to MMC layer so MMC layer thinks that
   SDCC is still enabled and skips call to msmsdcc_enable() until
   msmsdcc_disable() succeeds.
8. Note when msmsdcc_disable() returned error, RPM usage_counter was set to
   0 so next call to msmsdcc_disable() decrements RPM usage_counter to -1
   (remember msmsdcc_enable() was skipped).
9. Now new MMC request comes in and it will first call msmsdcc_enable()
   which calls pm_runtime_get_sync() and it sets the usage_counter to 0
   and blindly resumes the SDCC as it was already suspended. After this
   RPM status will be RPM_ACTIVE.
10. Once MMC request is processed, it will call smsdcc_disable() which
    calls pm_runtime_put_sync() and it decrements RPM usage counter to -1
    and skips scheduling runtime suspend callback as RPM usage counter
    is not 0. RPM status remains in RPM_ACTIVE.
11. Now onwards for every new MMC transfer requests, 9 and 10 repeats and
    SDCC always stays in RPM_ACTIVE state forever.

How is this race condition fixed?

Above race is created because host->pending_resume is remaining sticky.
Following changes are done to ensure that pending_resume gets set and
cleared at appropriate places:
1. In SDCC platform resume callback, set the host->pending_resume flag
   only if RPM status is RPM_ACTIVE.
2. Clear the pending_resume flag once msmsdcc_runtime_resume() is
   completed.
3. In msmsdcc_enable() function, if pending_resume flag is set skip calling
   pm_runtime_get_sync() instead directly call msmsdcc_runtime_resume()
   because RPM status is RPM_ACTIVE.

In addition, this patch adds WARN() messages in case of failures in
msmsdcc_enable() and msmsdcc_disable() functions to capture more details
in error conditions.

CRs-Fixed: 373338
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
(cherry picked from commit 386ad800716b6660d40c677b57ee4bf8e4430329)

Change-Id: I2c3b61c1b153cfed6db8c90ae3f7334b8830b5f7
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: sps: add option for external block pipe reset

Clients can specify whether to ignore external block pipe reset
or not during BAM registration.

Signed-off-by: Yan He <yanhe@codeaurora.org>
(cherry picked from commit 821e276e5c19c80dcdf9c933acb6a3b0b9df0fce)

Change-Id: I1cde36cae8328c5b2cc5ec7f1dd053271f69e604
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
Revert "msm: copper: Temporarily stub out bus arbitration for copper"

This reverts commit 136fbcf233893186369f20472ae0af9d791e0ad3.
Since the dependent patches are merged, no longer need to stub out
rpm calls.

Change-Id: If02d5d5afccdab4b97ecd02c62b19174e1656725
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
(cherry picked from commit 8566000303351337859b6bdbdbd705c3beac7efe)
ehci_msm2: Fix enumeration during PHY suspend failure

PHY suspend fails as part of USB LPM at times. Currently, we are resetting
the PHY and Link during this failure case, but the EHCI stack is not reset
due to which we are seeing device enumeration failure cases. Fix this issue
by removing hcd and adding hcd back during PHY suspend failure.

CRs-Fixed: 382279
Change-Id: I2d69e75409ec2b783dbdd06de4f34fe0356c1c45
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
(cherry picked from commit ce16958d07cedf2c46c97a9b0088a410c1a464a2)
msm: clock-rpm: Set the sleep vote only for sleep set clocks in handoff

The RPM clock handoff is erroneously setting last_sleep_set_khz
for clocks that only vote in the active-set. This results in an
incorrect sleep set vote to the RPM that does not go away even
when the corresponding (peer) sleep-and-active-set RPM clock is
disabled.

Set the last_sleep_set_khz value only if the clock in question
is not an active-set-only clock.

An example failure occurs as follows:

The system fabric clock is running at 192MHz on bootup. The
handoff code for the sfab_a_clk (the active set only clock)
sets last_set_khz and last_sleep_set_khz to 192MHz. Now, in
late_init, when sfab_clk is disabled, the sfab_a_clk's
last_sleep_set_khz value is sent to the RPM. This is wrong -
we are disabling the sleep-and-active-set clock, but we just
sent a rate of 192MHz to the RPM as our sleep set vote.
When the apps procesor transitions to the sleep set, if there
have been no other votes for sfab_clk and sfab_a_clk, the RPM
will figure that the apps needs 192 MHz on the system fabric
in the sleep set, even though sfab_clk on the apps side is
"disabled".

With the fix in place, sfab_a_clk's last_sleep_set_khz is 0,
and therefore when sfab_clk is disabled, the correct vote of
0 goes to the RPM.

CRs-Fixed: 392302
Change-Id: Iee47a3c4e683e335454d2485c4c4c5b1bc0d772c
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
(cherry picked from commit af72b71744e4c09ba210f2a68f1961dfe4d34c25)
leds: leds-qpnp: Add QPNP PMIC led driver

QPNP (Qualcomm Plug N Play) LEDs driver is used for
controlling LEDs that are part of PMIC on Qualcomm reference
platforms. The PMIC is connected to Host processor via
SPMI bus. This driver supports various LED modules such as
WLED (white LED), RGB LED and flash LED. The first version of
the driver supports WLED and other features are added in the
next versions.

Change-Id: Ib2962c784cf566905f909faa0d46f8ebfee77b2d
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
(cherry picked from commit f3d5a06505faa2d7690ad48ce7bb5e32afb56df2)
regulator: qpnp-regulator: Update boost regulator current limit reg address

Update the address used for the boost regulator current limit
register to reflect the correctly location in hardware.  The
proper address is 0x4A, not 0x40.

Change-Id: Ieefcd072858691940103664a2130a6c69341448f
Signed-off-by: David Collins <collinsd@codeaurora.org>
(cherry picked from commit 6f84675e8ca540df1ab704b527db672a2c229c78)
regulator: qpnp-regulator: Add support for rev 1 N1200 and N600 LDOs

The mapping between voltage control register set point values and
physical output voltage changes for range 1 of N1200 and N600
LDOs between PM8941 v1 and PM8941 v2.  LDOs with the previous
mapping have digital major revision equal to 0.  LDOs with the
new mapping have digital major revision equal to 1.  Modify the
qpnp-regulator driver so that the digital major revision register
value is taken into account when deciding which voltage mapping
to utilize.  N1200 and N600 regulators have identical
(range, voltage set point) --> output voltage mapping.

N1200 LDO range 1 hardware set points (rev=0):
375 mV to 768.75 mV with 6.25 mV step size

N1200 LDO range 1 hardware set points (rev=1):
375 mV to 1537.5 mV with 12.5 mV step size

Configure qpnp-regulator to use only range 0 for N1200 rev 1.
Range 0 is used because there is no benefit to using ranges 1 or
2 given that they have the same maximum voltage and step size
and their minimum voltage is greater than or equal to that of
range 0.

Change-Id: Icac6a1d8fccc014a754843d61c1fa40f550f9c77
Signed-off-by: David Collins <collinsd@codeaurora.org>
(cherry picked from commit bad606a7739aae9f79d45a394b39d6d321ee793e)
msm: smem_log: Initialize SMEM log after SMD

The smem_log dependency on SMSM is a legacy dependency that waited
for the modem to allocate the SMEM items before smem_log was initialized.
Now that smem_log can allocate the items first if necessary, it no longer
needs to wait for the modem since the only true dependency is that the
SMD module has initialized SMEM.

Update dependency information to initialize smem_log once SMD has
been initialized.

CRs-Fixed: 389529
Change-Id: I452eb31c8d2d1aea8ae02f8786a8c46f98c3ca2c
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
(cherry picked from commit fa44cd76ee424d4cfae2595ff69cff0510a94518)
msm: lpm_resources: Initalize L2 flush flag

L2 flush flag needs to be initialized to 0 in probe,
else the value defaults to 1, will result in L2
being flushed when all cores are power collapsed.

Change-Id: I0912b4053bf7f0bda01b5918a48ac3140b103d1e
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
(cherry picked from commit c2a53cb3d08533f86ab27d88391c7d3696c52816)
Bluetooth: Fix for supervision timeout must be 6X connection interval

Added a new function to verify whether the LE Connection Update
parameters are valid instaed of verifying all the LE Connection
parameters since only update parameters are set in the Connection
Update Request.

CRs-Fixed: 387146
Change-Id: I9fe6b51e44e2793f3945613fdfde3a039804746f
Signed-off-by: Archana Ramachandran <archanar@codeaurora.org>
(cherry picked from commit 95319af0612d58788279748f586cc57221c3443e)
msm_serial_hs: Don't destroy mutex from msm_hs_shutdown()

mutex is used uninitialized while unloading N_TTY line discipline
and installing SMUX Line discipline as msm_hs_shutdown() of HSUART
driver is called which is destroying this used mutex. Hence while
SMUX Line discipline is used, and clock off API is called, mutex
slowpath warning is seen. Destroying of mutex shouldn't be done from
msm_hs_shutdown() as initizalition and destroying of the mutex
is done from probe() and remove() of HSUART driver. Hence don't
destroy mutex from msm_hs_shutdown() to fix the issue.

CRs-Fixed: 391551
Change-Id: I74ac1372405e1b893d658ee03e9955858c9e782f
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
(cherry picked from commit d21314cc42558fe60cb0052bb1b645985f6be456)
Bluetooth: hci_ibs: Vote on/off UART clocks in non atomic context.

As per the latest clock design, we should not vote for the clocks
in the atomic context.

CRs-fixed: 377905
Change-Id: I70f269d40f007326de7a6279bfd11c4e576d251b
Signed-off-by: Ram Mohan Korukonda <rkorukon@codeaurora.org>
(cherry picked from commit d0063b6620e90266599cec711d6c5160878d47ca)
msm: pil-q6v5-lpass: Add support for secure image loading

Use the scm-pas APIs to authenticate and securely boot signed images
when supported. This is very similar to secure peripheral support
present in previous PIL drivers.

Change-Id: I3b6be69ad2f30ff5ba8c5de93051276936a1ab44
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
(cherry picked from commit 10a5967199846c07ce31b1b3730e088557a734cb)
input: atmel_mxt_ts: Fix macro (CONFIG_OF) name usage.

Macro should be CONFIG_OF and not OF_CONFIG.

Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
(cherry picked from commit 56cb58c1b832760adfe382b845e52837b7ea7e85)

Conflicts:

	drivers/input/touchscreen/atmel_mxt_ts.c

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
(cherry picked from commit 54d1b97939cab0482aa5f4549e81ecf3599e2024)

Change-Id: I102d6871958a03ca596c7c538c539fcc27a4e14d
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>