msm_serial_hs: Add runtime support for determining UARTDM register offsets

Currently, HSUART uses a Kconfig option to determine the UARTDM core
version register offsets during compile time. This change adds runtime
configuration support for determining the version of the UARTDM core,
and use the same with appropriate register mappings in HSUART driver.

Also with addition of runtime support for determining the UARTDM core
version register offsets, Kconfig CONFIG_MSM_UARTDM_Core_v14 is no longer
required. This change also does clean up of defconfig files for removing
the config and uart register header files for achieving the same.

Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
defconfig: remove CONFIG_MSM_UARTDM_Core_v14

not needed after the previous commit

Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm_serial_hs: fix compilation warning

Add proper typecasting for the physical address type

Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Signed-off-by: Dilip Kota <c_dkota@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm_serial_hs: Disable RFR line and auto RFR in set_termios

This change disables the RFR line during set_termios call so that
the remote side does not send data during this call and thus prevents
data omission and corruption.

Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm_serial_hs: Configure UART RX gpio line as wakeup irq line

UART wakeup can be triggered by RX activity using a wakeup GPIO on the
UART RX pin. This change adds support for configuring the UART RX gpio
line as wakeup irq line.

Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
Signed-off-by: Ram Mohan Korukonda <rkorukon@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
platform/msm: qpnp-power-on: Implement cold_boot sysctl parameter

Update the cold_boot sysctl parameter by using
qpnp_pon_is_warm_reset API. cold_boot sysctrl
is updated with 1 or 0 when system was booted from
cold or warm boot states respectively.

Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: vidc: Check maximum width capability of Q6

Maximum width capability check is required to take
care of indefinite behavior when a clip having width
more than Q6 capability is played. Also, make the
capability check generic for Q6 and Venus.

Signed-off-by: Ravi Kiran Vonteddu <rvontedd@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
mmc: sdhci-msm: Correct usage of readl_poll_timeout() API

The intention of sdhci_msm_probe() was to wait up to 1ms for
CORE_SW_RST to be set, but only a 10us timeout was passed to
readl_poll_timeout().

Correct the timeout value to be 1ms, and decrease the sleep
time between read attempts to only 10us so that it's less
than the expected wait time of 40us.

Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
pktgen: clean up ktime_t helpers

Some years ago, the ktime_t helper functions ktime_now() and ktime_lt()
have been introduced. Instead of defining them inside pktgen.c, they
should either use ktime_t library functions or, if not available, they
should be defined in ktime.h, so that also others can benefit from them.
ktime_compare() is introduced with a similar notion as in timespec_compare().

Signed-off-by: Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
iopoll: Use ktime_get() instead of jiffies for timeout calculations

Presently, small timeout values will round up to 1 jiffy which,
on CONFIG_HZ=100 systems, corresponds to a full 10 milliseconds.
This is undesirable for drivers specifying timeouts of only a
few 10's of microseconds (which is common), since they may end
up tight-loop spinning for hundreds or thousands of times longer
than expected before reporting a timeout.

Additionally, jiffies cannot be reliably used with time_after()
when the value of jiffies is small (like 1). In rare but real
scenarios, jiffies may actually increment by more than 1 at a
time. Specifically, this will occur if interrupts are disabled
on for more than 1 jiffy (10 milliseconds for CONFIG_HZ=100) on
the CPU responsible for incrementing jiffies.

If interrupts are re-enabled on that CPU between the time the
iopoll code (on another CPU) calculates the timeout value of
jiffies and when the time_after() comparison is made, then the
iopoll APIs may return -ETIMEDOUT prematurely, even though the
specified timeout has not actually expired.

Using ktime_get() avoid this problem (which arguably also needs
a generic fix to avoid similar problems for other code which use
jiffies to calculate timeouts).

Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
mmc: card: quirk: disable cache for Kingston card

This change prevents enabling cache during card init for specific
Kingston card.
This change is workaround the problem of long timeouts for cache
operations.

Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: vidc: Free OCMEM during power collapse

To disable OCMEM clock during power collapse, video driver
has to free up the allocated OCMEM. This memory will be
re-allocated before bringing venus core out of reset.

Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: vidc: recover from firmware fatal error

If firmware goes in to bad state, the video driver
should try to restart the firmware, so that subsequent
new video sessions can play fine without error.
Previous to this change, the video driver would
unload the firmware only after all open instances
have been closed by the client. If the client fails
to close any of the open instances, then firmware
would not be unloaded and continue to remain in bad
state. This would fail all new video sessions and could
be overcome only after the device was reset.

Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: vidc: unprepare clocks during power collapse

If any clock is still prepared (only disabled), apps will
not vote for XO shutdown. Unprepared clocks will remove the
vote and facilitate XO shutdown.
During power collapse, video drivers now disable and
unprepare venus clocks.
There was minimal power savings during internal tests,
but customer reported to have impact of 13mA without
the change.
The change add different clock states. Clock state
transitions with clock api is shown below
====================  clk_prepare_enable()    ==================
|DISABLED_UNPREPARED| ----------------------  |ENABLED_PREPARED|
====================  clk_disable_unprepare() ==================
   ||                                                   ||
   || clk_unprepare() ================    clk_disable() ||
    -----------------|DISABLED_PREPARED| ---------------
      clk_prepare()   ================    clk_enable()

Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: vidc: ensure venus clocks are enabled while release buffer

While interframe clock gating, venus clock are gated ON and
OFF based on firmware response. It may happen that venus
clocks are disabled while iommu driver unmaps output buffers.
This may lead to unclocked memory access.
Venus clocks should be enabled while releasing output buffers.

Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
mmc: core: fix variable being overwritten

The status variable is being overwritten by label variable,
since the latter is an array of 0 length. Hence, move label
to be the last member of the structure.

Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: rq_stats: Use cpufreq API to get the current frequency

Since the acpuclock APIs are deprecated, use the cpufreq to
get the current frequency of CPUs to calculate the cpu
normalized load value.

Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: rq_stats: Fix wrong usage of cpufreq_quick_get()

cpufreq_quick_get() returns frequency in KHz, which is exactly what
cur_freq expect. Remove the wrong multiplication.

Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
qseecom: Replace kzalloc with ion_alloc

Allocate memory to common lib through kzalloc issues no page errors due to
higher order memory request. So allocate the memory from the heap specially
dedicated to QSEECOM.

Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
qseecom: Fix failure to load cmnlib image

Set the physical address field of load_req data struct
correctly using the right ion_phys API. Without this,
secure domain is not able to address/dereference memory
where cmnlib image resides.

Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>