spmi: Add del_controller functionality

The del_controller function is required to release any client device
resources as well as the debugfs entries.  This patch adds that
functionality.

Change-Id: I91c6b840acfe002f096570cbe1867b302c475e60
Signed-off-by: Kenneth Heitke <kheitke@codeaurora.org>
spmi and gpio: qpnp: add pointer check in qpnp drivers

This patch is to fix KW errors in drivers. It's
neccessary to check NULL pointer before dereferencing it.
There're 4 issues related to it in qpnp-int.c and
qpnp-pin.c. Fix them by checking before.

CRs-Fixed: 505322
Change-Id: I2f82d1b24c219ef7e6b0977091fc353dac579cbc
Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>

Conflicts:
	drivers/spmi/qpnp-int.c
spmi: Add check for NULL and invalid controller pointer

Replace the BUG_ON() check with a NULL pointer check and verify that
the controller type is set appropriately.  This prevents a system crash
due to invalid input.

Change-Id: I858980ad54ba0d764219049a20b4ca3e9b77f72e
Signed-off-by: Kenneth Heitke <kheitke@codeaurora.org>
spmi: qpnp-int: call arbiter ops only when all peripheral irqs are disabled

The current driver calls arbiter ops when an interrupt is being
masked or unmasked. However, the arbiter ops were meant to be
called if all interrupts for a peripheral were disabled or
the first enable happens.  The driver ends up masking the peripheral
(i.e.  all the interrupts in that peripheral) if any one interrupt in
that peripheral is masked. There could be other interrupts enabled
which will not trigger after this.

Fix this by changing the driver to call the arbiter ops only
when all the interrupts in the peripheral are disabled or when
the first enable of an interrupt in that peripheral happens.

Also take this opportunity to clean up the arbiter ops calls to
specifically write to the INT_ACC_ENABLE bit instead of entire
register as specified in the data sheets.

Change-Id: If5835ac125f59d2964242758aa9f9ef145000af7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
spmi: qpnp-int: show resume irq

Add code to print the interrupts that woke up the device from
resume. Use syscore resume operation to print the interrupt
number.

Since most of the systems have only one arbiter control, it is
reasonable to create a file scoped PMIC arbiter pointer for the
syscore resume operation.

CRs-Fixed: 502334
Change-Id: Ib4be9273633a70527a853fb5792543d66c8d2303
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
spmi: Inline a function to remove compilation error

Compilation error is seen in spmi_dfs_add_controller
function when debug fs is disabled.
In this patch this function is defined as static
inline to remove this error.

CRs-Fixed: 555022
Change-Id: I66ac9ca9eeb1e25c68c9deff665258f4e036a678
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
diag: dci: Safeguard to prevent Integer Underflow and Memory Leak

At certain point in diag driver there can be integer underflow
thus can lead to memory leak. Added a safeguard for that.

Change-Id: I2a0304f5b9888fe12ca9ef5fbaa9a68ee4ab9c15
Crs-fixed: 556860
Signed-off-by: Katish Paran <kparan@codeaurora.org>
misc: isa1200: Change mutex for isa1200 vibrator

Change i2c client device mutex to local driver mutex
for isa1200 vibrator which is used while enabling and
disabling the clock.

CRs-Fixed: 545512
Change-Id: I4f61c629c503c658410b5c14da2e1612b82ec201
Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
msm: ipa: Send state changed event from IPA RM

In case that producer is granted synchronously, notify all
registered clients. This change is required as there was an IPA RM
client which didn't get the notification when required.

Change-Id: If400c5d4c48ae856a39277cfd1bdc4c27bf67372
Signed-off-by: Vladislav Mordohovich <vmordoho@codeaurora.org>
msm: ipa: Change the value of HOLB timer

Change the value of HOLB timer from 0xff to 0x1ff.
This change is needed for TCP good bi-directional throughput.

Change-Id: Ib8e147fdda901e0bfc21c57c3853340ae3f68c20
Signed-off-by: Vladislav Mordohovich <vmordoho@codeaurora.org>
msm: ipa: Adding debugfs stats to IPA RM

Adding statistical information regarding IPA RM

Change-Id: I03c3e95f5cf7e7568fbe7778965ea1b2b80a96fe
Signed-off-by: Vladislav Mordohovich <vmordoho@codeaurora.org>
msm: ipa: Bug fix in RM add_dependency

Fixing a minor bug in the RM at add_dependency

Change-Id: Icb6a53cd6b4bdbd590adea52725f7df688e0a2f0
Signed-off-by: Vladislav Mordohovich <vmordoho@codeaurora.org>
msm: ipa: a2_service: race condition fix

This issue is a rare race condition which appears after ~3 hours of
testing and causes a kernel crash.

Fixes the issue reported in droidbug-60712.

Change-Id: Id6d313088f7873ef3f47edeb25c54528691ece5b
Signed-off-by: Gidon Studinski <gidons@codeaurora.org>
msm: ipa: Move ipv4 RT rules to use system memory

Moving ipv4 routing rules in IPA-HW to use DDR memory.
By default ipv4 routing rules will reside in DDR memory.

Change-Id: I69c559ca90b638e38af872a3858f3fcb6e61d0b0
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
msm: ipa: wwan: release producer only when no outstanding packets

release WWAN_PROD only after getting WRITE_DONE
event for the last packet to make sure that there
is no outstanding packets when releasing WWAN_PROD.
This is fix for potential bug that A2 may go to
power collapse while there are packets pending in BAM

Change-Id: I6ae08fb149f4309866b693f37744e090581f5816
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
msm: ipa: use smem_alloc2 to allocate SMEM pipe mem

smem_alloc used previously assumes modem will alloc the
item before IPA driver is initialized. smem_alloc2 will
alloc the item if not already allocated.

Change-Id: I4bd1e8d85a325180e58507b300984db882d8e18d
Signed-off-by: Ravi Gummadidala <rgummadi@codeaurora.org>
qpnp: pwm: Add Keypad Backlight Lookup Table support

The Keypad Backlight Lookup Table (KPDBL_LUT) is similar to
a generic LUT found in PM8941 pmic with a minor differences such
as 8 bit LUT entry, and less LUT entries than generic LUT. Add
support for KPDBL_LUT to the PWM driver.

CRs-Fixed: 503480, 505751
Change-Id: Ice7b18e4b7681480e07bf25f4c258cfcbe58cb4d
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>

Conflicts:
	drivers/platform/msm/qpnp-pwm.c
qpnp: pwm: Remove LUT mode dependency of PWM driver

Some low cost Qualcomm pmic chipsets such as PM8110 do not
have LUT slice in their PWM module. In the existing PWM driver
design, it does not probe if LUT base address is not provided
in device tree. PMICs that do not support LUT mode do not have
LUT base address populated, which is perfectly fine.

Thus, remove the requirement to always have LUT base address
present and check if LUT mode is supported during operations that
involve LUT mode.

CRs-Fixed: 490081
Change-Id: Ie705172b21d13120cf96781840c3cc6ef4160851
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>

Conflicts:
	drivers/platform/msm/qpnp-pwm.c
msm: ipa: change release producer RM API to always return success

A bug fix in RM, which caused the producer to remain in
"release in progress" state when releasing producer.
The fix is to move to release state directly without
moving to "release in progress" state.

Change-Id: I588780898b7b234bbc3233f661f7bb90e34ce598
Signed-off-by: Vladislav Mordohovich <vmordoho@codeaurora.org>
qpnp: pwm: Add delay to disable/enable pwm

Need some time to ensure the pwm disable/enable.
If not, sometimes pwm is not enabled correctly.

Bug: 9772457
Change-Id: Ia5fd03b8395c2126744776ecfda33670acfb4596
Signed-off-by: sungjin.yun <sungjin.yun@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>