Added imoseyon's USB fast charge

Signed-off-by: thirdzcee <thirdzcee@gmail.com>
Voltage Control

Signed-off-by: thirdzcee <thirdzcee@gmail.com>

Conflicts:
	arch/arm/mach-msm/Kconfig
Just some commits for slimbus

msm: slimbus: Optimize overclocking of master component

(cherry picked from commit 9837f3f2d926ea4ab92be0351d18950d3fe88368)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

msm: slimbus: enhancements mkII

This time we keep the root freq to 11.
If Root Freq is set at 11, 24,576MHz has the best compatibility for all present sampling rates (e.g, any sample rate can be converted, 48KHz to 96KHz, 44.1KHz to 96KHz, 48KHz to 128KHz etc.) Increasing the root frequency is likely to cause invalid present sample rate combinations which leads to audio glitches such as distortion. "A Natural Frequency is defined as a CLK frequency that allows a family of data rates to be supported. The different sample rate flows can be optimally supported by changing a particular Natural Frequency using the Clock Gear." I looked at a Clock Gear/RF table and it looks like CLK Gear 10 and RF 24,576MHz (Stock RF) is an excellent combination due to its compatibility towards every other sample rates.

ZeroInfinity/Poondog

Signed-off-by: ZeroInfinity <infinitezero345@gmail.com>
Signed-off-by: poondog <markj338@gmail.com>
Signed-off-by: flar2 <asegaert@gmail.com>
(cherry picked from commit 7ae961654210fdb7dd6d979567b4fb60f92569cf)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

msm: slimbus: some more tweaks and added new freqs

Set ROOT_FREQ at 22, which is double what we had before.
According to some documents this is what we want for optimium audio quality
Forcec SLIM_RATE to 44.1KHz and 48KHz instead of much lower values.
This way it will be forced to run at these freqs to match the majority of audio files user will be playing.

ZeroInfinity/Poondog

Signed-off-by: ZeroInfinity <infinitezero345@gmail.com>
Signed-off-by: poondog <markj338@gmail.com>
Signed-off-by: Lens-F <tnoah12@gmail.com>
(cherry picked from commit 3e7369e7d0deef6d44c1027f005fc8c64d867358)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

Conflicts:
	drivers/slimbus/slimbus.h

slim_msm: Fix unsafe locking in msm_sat_enqueue()

msm_sat_enqueue() calls spin_lock() and msm_sat_dequeue() calls
spin_lock_irqsave(). This leads to lockdep warnings about the
same lock being taken in interrupts on and interrupts off context
which can lead to a potential deadlock.

=================================
[ INFO: inconsistent lock state ]
3.4.0+ #382 Tainted: G        W
---------------------------------
inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
kworker/u:2/94 [HC1[1]:SC0[0]:HE0:SE1] takes:
 (&(&sat->lock)->rlock){?.+...}, at: [<c0348b80>] msm_sat_enqueue+0x20/0xb0
{HARDIRQ-ON-W} state was registered at:
  [<c00bd290>] __lock_acquire+0x664/0x8d8
  [<c00bd690>] lock_acquire+0x18c/0x1e8
  [<c06989a4>] _raw_spin_lock+0x38/0x48
  [<c0348b80>] msm_sat_enqueue+0x20/0xb0
  [<c0349338>] msm_slim_rxwq+0x278/0x42c
  [<c0349580>] msm_slim_rx_msgq_thread+0x94/0x1f8
  [<c008e480>] kthread+0x90/0xa0
  [<c000f438>] kernel_thread_exit+0x0/0x8
irq event stamp: 24219
hardirqs last  enabled at (24218): [<c0699188>] _raw_spin_unlock_irqrestore+0x3c/0x68
hardirqs last disabled at (24219): [<c06993f4>] __irq_svc+0x34/0x78
softirqs last  enabled at (24129): [<c00738a8>] irq_exit+0x54/0xa8
softirqs last disabled at (24108): [<c00738a8>] irq_exit+0x54/0xa8

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&(&sat->lock)->rlock);
  <Interrupt>
    lock(&(&sat->lock)->rlock);

 *** DEADLOCK ***

3 locks held by kworker/u:2/94:
 #0:  ((sat->satcl.name)){.+.+.+}, at: [<c0087124>] process_one_work+0x1e8/0x648
 #1:  ((&sat->wd)){+.+.+.}, at: [<c0087124>] process_one_work+0x1e8/0x648
 #2:  (&dev->tx_lock){+.+...}, at: [<c0349cac>] msm_xfer_msg+0xb4/0x51c

stack backtrace:
[<c00151b0>] (unwind_backtrace+0x0/0x120) from [<c00b9d48>] (print_usage_bug+0x258/0x2c0)
[<c00b9d48>] (print_usage_bug+0x258/0x2c0) from [<c00ba12c>] (mark_lock+0x37c/0x68c)
[<c00ba12c>] (mark_lock+0x37c/0x68c) from [<c00bd20c>] (__lock_acquire+0x5e0/0x8d8)
[<c00bd20c>] (__lock_acquire+0x5e0/0x8d8) from [<c00bd690>] (lock_acquire+0x18c/0x1e8)
[<c00bd690>] (lock_acquire+0x18c/0x1e8) from [<c06989a4>] (_raw_spin_lock+0x38/0x48)
[<c06989a4>] (_raw_spin_lock+0x38/0x48) from [<c0348b80>] (msm_sat_enqueue+0x20/0xb0)
[<c0348b80>] (msm_sat_enqueue+0x20/0xb0) from [<c0348dc8>] (msm_slim_interrupt+0x1b8/0x4b0)
[<c0348dc8>] (msm_slim_interrupt+0x1b8/0x4b0) from [<c00d2ccc>] (handle_irq_event_percpu+0x118/0x3a4)
[<c00d2ccc>] (handle_irq_event_percpu+0x118/0x3a4) from [<c00d2f94>] (handle_irq_event+0x3c/0x5c)
[<c00d2f94>] (handle_irq_event+0x3c/0x5c) from [<c00d5c4c>] (handle_fasteoi_irq+0xd0/0x11c)
[<c00d5c4c>] (handle_fasteoi_irq+0xd0/0x11c) from [<c00d2ae4>] (generic_handle_irq+0x24/0x2c)
[<c00d2ae4>] (generic_handle_irq+0x24/0x2c) from [<c000f370>] (handle_IRQ+0x7c/0xc0)
[<c000f370>] (handle_IRQ+0x7c/0xc0) from [<c0008774>] (gic_handle_irq+0x6c/0xc4)
[<c0008774>] (gic_handle_irq+0x6c/0xc4) from [<c0699404>] (__irq_svc+0x44/0x78)
Exception stack(0xee061cd8 to 0xee061d20)
1cc0:                                                       00000001 eebda7c8
1ce0: 00000000 eebda400 20000013 c12b5430 ec96c168 c12b542c c12b5430 00000001
1d00: 20000013 ee061e14 3eb13eb1 ee061d20 c00ba520 c069918c 20000013 ffffffff
[<c0699404>] (__irq_svc+0x44/0x78) from [<c069918c>] (_raw_spin_unlock_irqrestore+0x40/0x68)
[<c069918c>] (_raw_spin_unlock_irqrestore+0x40/0x68) from [<c0279f2c>] (__debug_object_init+0x30c/0x344)
[<c0279f2c>] (__debug_object_init+0x30c/0x344) from [<c007b068>] (init_timer_on_stack_key+0x18/0x30)
[<c007b068>] (init_timer_on_stack_key+0x18/0x30) from [<c0695248>] (schedule_timeout+0x8c/0x4c0)
[<c0695248>] (schedule_timeout+0x8c/0x4c0) from [<c069768c>] (wait_for_common+0xec/0x164)
[<c069768c>] (wait_for_common+0xec/0x164) from [<c0349fc4>] (msm_xfer_msg+0x3cc/0x51c)
[<c0349fc4>] (msm_xfer_msg+0x3cc/0x51c) from [<c034a358>] (slim_sat_rxprocess+0x244/0x664)
[<c034a358>] (slim_sat_rxprocess+0x244/0x664) from [<c0087290>] (process_one_work+0x354/0x648)
[<c0087290>] (process_one_work+0x354/0x648) from [<c0089754>] (worker_thread+0x1a8/0x2a8)
[<c0089754>] (worker_thread+0x1a8/0x2a8) from [<c008e480>] (kthread+0x90/0xa0)
[<c008e480>] (kthread+0x90/0xa0) from [<c000f438>] (kernel_thread_exit+0x0/0x8)

Make this lock irqsafe as well so that this potential bug doesn't
occur.

Change-Id: Icbef6d1d749ee6ee81b079e19e57f22c38f00c68
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit 45cf39c1b61b43a2fede285ec83cc4b9782b7975)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

slim_ngd: Slimbus satellite controller driver

NGD (non-ported generic device, also known as satellite device) is
used to implement light-weight slimbus controller driver.
This driver is responsible for:
1. Communicating with codec (or any slimbus slave registered from
application processor side) directly using slimbus HW messaging
interface.
2. Communicating with the manager device (controller by master driver)
on LPASS to do bandwidth and data channel management. NGD takes these
requests from slimbus slave on application processor side and passes
them to the manager device using slimbus messaging itself.
SPS BAM is used for receiving messages to offload CPU, and to enable
receiving multiple messages before driver can process them.
Runtime-pm is used for power management. Controller is in active
power state when messaging and/or data-channels are active from
application processor side.

Change-Id: Iff53c0ca9b768a3dac3bccb5004fd2f96070af50
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
(cherry picked from commit 8bb8b2b358eb6213646130041b99581ce685485e)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

Conflicts:
	drivers/slimbus/Makefile
	drivers/slimbus/slim-msm.h

slim_ngd: Rectify define, removal messages per protocol

Populate required bits only as client handle while sending
channel define, removal messages to the master driver.
Previously, complete logical address was set as client handle
which would corrupt other fields in that byte if logical
address had non-zero MSBs. This patch fixes that problem.

Change-Id: I96e8a7917c1fe68e1c86f6837c0b9f8ee187ca3d
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
(cherry picked from commit 13dcea169cd23d72e719cb03230cb62d38930906)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

slim_ngd: Support reserving message bandwidth for clients

Message bandwidth can be reserved by clients to do message-intensive
transactions over Slimbus. While slimbus framework supports that,
NGD driver was missing corresponding code to send this request to
master driver on ADSP. This patch adds that support.

Change-Id: If6a340746816658ac0aa1b4bd7c2270205eb6d4a
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
(cherry picked from commit 83e990f772ce63ae43c36af9391fbebbe70a4b71)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

slim_ngd: Make sure transaction is not dereferenced after it's freed

Every read transaction over slimbus is a set of one transmit and one
receive. Receive part frees meta-data for the read transaction since
it is no longer needed, and the transaction-ID can be reused.
Make sure that the transmit function doesn't try to dereference the
transaction meta-data after possibly receiving a response.

CRs-fixed: 515802
Change-Id: Id736ad368d4944a6aabc89f4ff295d664bc5efa0
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
(cherry picked from commit 570839de57931f7c3fd23451c865cf31c7e5be68)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

slim_ngd: Add NULL pointer check apart from error check

Check against NULL pointer after allocating
the memory for msm_slim_ctrl structure pointer
dynamically to avoid unexpected crashes.

Earlier this pointer is checked only for error
codes. In this patch NULL pointer check is also
added.

Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: poondog <markj338@gmail.com>
(cherry picked from commit c32b6082622ee659a5f1fd650c786ab9f25071d8)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>
earlysuspend: speedup late resume (faster wakeup of the device)

Thanx to _2bad4u_ for the hint and dsc-team's repo I got the code from (https://github.com/dsc-team/dsc-team-kernel-project)

(cherry picked from commit 8e2295c46627d1840ae37ecbc84cb03e8ba4e9b8)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>
SQUASH qpnp stuff

msm: qpnp-power-on: Add API to reset and shutdown the system

Add an API to allow the system to reset or shutdown, depending on
the parameter passed. The qpnp-power-on driver supports any number
of PON devices, but only one device is permissible to reset the
device. Introduce a new Device Tree binding to indicate which
device should be responsible for this resetting the system.

Change-Id: I4086b50402a5c997fb0efada3e65116eec8f4e53
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
(cherry picked from commit 6e34b5121de2ff881cb432e23eec857c168c1314)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

msm: qpnp-power-on: Add API to detect warm reset

Add an API to allow consumers to know whether the PMIC went through
a warm or cold boot. This currently only checks the PON device that
allows resets.

Change-Id: Id145ec62bbdf0e4988476f2c2084f92c3f588209
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
(cherry picked from commit 6cc3271dd893a71b293f456f3755d38d4aa943ba)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

Conflicts:
	drivers/platform/msm/qpnp-power-on.c

msm: qpnp-pon: Add API to configure the PON trigger source

The API enables/disables power-on trigger capability of a PON source.
If a specific PON trigger is disabled it cannot act as a power-on
source to the PMIC.

CRs-Fixed: 489577
Change-Id: Ibec2063215eafc47701a3e255849e16f1d7b2cee
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
(cherry picked from commit d73f989ff223a07fa60981c7b05793e7dade2574)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

Conflicts:
	drivers/platform/msm/qpnp-power-on.c

msm: qpnp-power-on: Add finer control of PMIC power off type

Modify the qpnp_pon_system_pwr_off() function so that different
types of PMIC reset may be requested.  In particular, add support
so that both warm and hard reset may be used.  Warm reset
maintains the hardware state of some PMIC peripherals.  Hard
reset resets all PMIC peripherals.

Change-Id: Ibe1491acfe90364e96b776d26e158522dfea9c2b
CRs-Fixed: 507850
Signed-off-by: David Collins <collinsd@codeaurora.org>
(cherry picked from commit 06b96aa19e77ddeccacb1f5815ac781b963e971c)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

Conflicts:
	arch/arm/mach-msm/restart.c

Signed-off-by: thirdzcee <thirdzcee@gmail.com>
Default to noatime/nodiratime

Signed-off-by: thirdzcee <thirdzcee@gmail.com>
Squash 'enhance power efficiency' patches

Series of patches from NVIDIA on some critical blocking
code paths to allow the CPU to relax instead of busy spinning
thus lowering the load_average and lowering power consumption.

Signed-off-by: Sumit Singh <sumsingh@nvidia.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: flar2 <asegaert@gmail.com>
(cherry picked from commit 414056476daa97d1f725b5aa63eb4c1448026d3f)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>
sched: Add controls for sched features

* Currently we provide users attributes to enable/
  disable GENTLE_FAIR_SLEEPERS and ARCH_POWER
* This patch uses already implemented GFS structure
  to add ARCH_POWER attribute.
* Attributes can be found under /sys/kernel/sched/*

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
(cherry picked from commit fbcd2301e8313e6dc877ed0f7ae2c6401684c888)
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

Conflicts:
	kernel/ksysfs.c
	kernel/sched/fair.c

Signed-off-by: thirdzcee <thirdzcee@gmail.com>
drivers: usb: Use Android device as USB keyboard/mouse

Base project: https://github.com/pelya/android-keyboard-gadget
Required app: https://play.google.com/store/apps/details?id=remote.hid.keyboard.client

Steps:
* Start ADB Debugging
* Start app
* Connect device to system via USB cable

All credits to @pelya for this sweet hack.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
(cherry picked from commit 47e2324b5814b0f1928d0ed04c9f8d56b945aa3c)
Signed-off-by: thirdzcee <thirdzcee@github.com>
Signed-off-by: thirdzcee <thirdzcee@gmail.com>

Conflicts:
	drivers/usb/gadget/android.c

Signed-off-by: thirdzcee <thirdzcee@gmail.com>