ARM: dts: msm: use a corner regulator for wcnss VDD_CX on all boards

Update wcnss nodes to use voltage corner regulators for VDD_CX on MSM8226,
MSM8610, MSM8974, and MSM8974Pro.

Also update the wcnss platform driver to use voltage corner values for the
VDD_CX regulator supply.

Change-Id: I766b5e15bfdb0c68011fd2a27886026f754bdefd
Signed-off-by: Yue Ma <yuem@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: krait-regulator: add support for auto mode

On certain PMIC the AUTO mode for the ganged regulator operates
within spec. Allow the driver to use the auto mode and skip
controlling  PFM/PWM mode switching.

Enable support for using auto mode configuration.

Change-Id: Id4b0b39e0022496844a5f5bc1a37e4795ddd9c5b
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: krait-regulator: auto mode workarounds for pm8841

On pm8841 before enabling automode set the pwm current limit to
2Amps and reset it back to 3.5Amps after disabling automode.
This helps prevent overshoot when pfm-pwm switch happens while
running in auto mode.

Change-Id: I001c1aa649d7eed629e48cbb6d97194681e43d1b
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ARM: dts: enable auto mode for MSM8974 based devices

Enable auto mode for MSM8974 based devices. Auto mode is enabled
only in single phase configuration, allows us to switch between
pfm and pwm mode based on the load profile.

Change-Id: I1901420ff4720aa911c75b7f86ef725273b30ed1
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
dwc3: gadget: Add support for transfer complete events counting

Add counting of USB transfers completion events/interrupts
so that it can be used to determine USB transfers or BUS usage.
This is a simple approach which gives reasonable accuracy to
avoid counting actual bytes that got transferred over USB.

CRs-fixed: 687220
Change-Id: Ib06e916ef1b3a7dbf0b3c720d306e922043a7f33
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
USB: msm_otg: Process HOST disconnect only after system RESUME

If Host Cable (ID_GND) is disconnected in system suspend then
it results in race between device removal and device pm_resume.
PM core does't handle this correctly and sometimes frees up
parent device before children are resumed. To avoid this race
make sure that system has resumed completely before handling
ID_FLOAT (or host cable disconnect) event.

CRs-fixed: 652870, 651561
Change-Id: Id0956a9677d819d3fa3f17f54965cae38f2ee31d
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
USB: msm: Add support for MSM_USB_EXT_CHG_TYPE ioctl

Add support for MSM_USB_EXT_CHG_TYPE ioctl in driver for userspace to
notify kernel whether charger connected is external charger or not.

CRs-Fixed: 652965
Change-Id: I13095b4183efe3cfc690b7a9cb4f3c2d3cb4ee73
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
USB: Fix bug in ext_chg_active flag handling

The ext_chg_active flag is set to true when the external charger
processing is pending. It is set to true when DCP is detected and
set to false when the user space notifies that it is done with
the charger detection. The user space may unblock the low power mode
any time to access the hardware to request a new voltage setting.
The current code does not set ext_chg_active flag in this case due to
which USB enters low power mode while external charger processing
is pending. This results in unclocked register access.
Fix the issue by setting ext_chg_active to true every time the
userspace calls the block LPM.

CRs-Fixed: 663301
Change-Id: If18f762d7fc0b4eaba297e27bbd7382b161fbcde
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
usb: msm_otg: Fix bug with hvdcp connect and disconnect processing

The HVDCP charger is detected as a DCP charger by the USB driver. When a
DCP is detected, ext_chg_active flag is set to true and low power mode is
deferred by 3 seconds. When the user space receives the DCP connect uevent,
it kicks the charger detection algorithm. The charger detection procedure
involves reading and writing to the USB hardware registers and it makes an
ioctl call to block the low power mode by incrementing the pmruntime usage
counter. The user space calls the ioctl to unblock low power mode once
hvdcp detection is done by decrementing the pmruntime usage counter .

Consider the scenario where DCP detection is done and userspace makes
ioctl call to block low power mode. Next usb cable is disconnected and then
userspace makes ioctl call to unblock the low power mode by decrementing
the pmruntime usage counter. Due to this runtime suspend gets called and
USB clocks are turned off which later leads to unclocked access in
disconnnect processing. As part of USB disconnect, phy reset is done which
also involves ulpi register access. As clocks are turned off, it leads to
crash.

Fix the issue by making sure otg_sm work for usb disconnect is processed
first followed by decrementing the pmruntime usage counter in the ioctl
call made by userspace for unblocking the low power mode.

CRs-Fixed: 668648
Change-Id: I91db5f2e1084ae8f65dd8ec51c4314acc764c9c5
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
USB: ci13xxx_udc:  Add support for UI interrupts counting

Add counting of UI or USB transfers completion interrupts
so that it can be used to determine USB transfers or
BUS usage. This is a simple approach which gives
reasonable accuracy to avoid counting actual bytes
that got transferred over USB.

Change-Id: I1ee3c6997e40ee5db1da26af1e68fced06ea2de4
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
usb: msm_otg: Fix timeout during usb disconnect with hvdcp charger

Once DCP is detected, ext_chg_active is set to true and DCP uevent
reached to user space. The hvdcp main thread mark dcp_connected to
true and wakesup the detector thread to do hvdcp detection. But before
the detector thread gets a chance to run, DCP is removed. The disconnect
uevent reached the user space and the hvdcp main thread marks the
dcp_connected to false and it will not call any ioctl call. As
ext_chg_active is still set to true, it is waiting for 3 seconds while
processing usb disconnect.

Also it is possible that DCP uevent is reached to the user space much
before ext_chg_active flag is set to true in otg state machine work which
later leads to timeout of 3 seconds later while processing usb disconnect.

Fix these issues by maintaining different states for ext_chg_active. Upon
DCP disconnect, if the ext_chg_active value is still default, mark it to
inactive. This avoid the 3 seconds wait timeout while processing the usb
disconnect.

CRs-Fixed: 671181
Change-Id: Ic4aa6745e994a007bd6bd2e75d4f44fb8f7ac9c1
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ARM: dts: msm: Add CX regulator Phandle to MDP node

The Phandle might change for different versions of
the msm8974 chip. Add the proper Phandle of CX regulator
to 8974pro version.

Change-Id: I6e8ab19c9765ff225a54a621cd001e8af1c7391d
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
arm/dts: Cleanup duplicate entry in sound config

Change-Id: I71b3f4f6d8ef0981d057557e9b421fcabf662060
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
usb: dwc3: Add support to disable hsphy auto suspend feature

Currently hsphy auto suspend is enabled by default. There are few
issues using this feature as it is required to disable this
functionality before sending different endpoint and generic commands
to core and re-enable after the same. Hence this change adds support
to disable hsphy auto suspend feature if it is required.

CRs-Fixed: 625668
Change-Id: Iec585aefe83fb5710152dd6e4627fcba767cd262
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
USB: dwc3: Add support for fixing superspeed enumeration issue

Setting SSPHY SUSP bit (bit 17) in GUSB3PIPECTL(0) register
might cause device enumerating at high speed mode instead of
superspeed mode on some platforms. Hence add workaround by
clearing the SSPHY SUSP bit during disconnect and setting it
after it is configured to fix this enumeration issue on those
platforms.

Also add support for disabling U1 and U2 low power modes  which
could also affect this enumeration issue.

CRs-Fixed: 637902
Change-Id: I8668ced09a88b77f37265ab15e89fa9e964bfbe9
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ARM: dts: msm: Update the vifeed back routing

Codec clock should be enabled when vifeedback path for speaker
protection is enabled.
Change adds the routing entries to enable the codec clock for
speaker protection vi capture feedback path for 8974.

Change-Id: I6230f5a40a20a3d5e81d194a622083ece8873b79
CRs-fixed: 591723
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
misc: Kill logspam

Change-Id: Ida0b1eaeda4c678f0103675b44a8cc845f3dacbf
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: msm: Rampup volume on each start

Rampup volume on each trigger start call to compress driver.
This helps in reducing pops heard by the listener after a seek/pause+resume

Change-Id: I0d82c5a9a8ed2b64683e8c0855da2208c90d8199
Signed-off-by: Haynes Mathew George <hgeorge@codeaurora.org>
CRs-Fixed: 692337
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: msm: qdsp6v2: Add a new waitqueue state for mem map/unmap

All of the commands being sent to the DSP are using cmd_state flag
which can be overwritten when several commands are sent at the same
time. This results in Memory map command timing out. The change will
separate the memory flag from flags for other commands so that they
do not overwrite each other.

CRs-fixed: 673781
Change-Id: I61e059f402feb2c4e1e3dbed1825990456e78471
Signed-off-by: Damir Didjusto <damird@codeaurora.org>
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
mfd: wcd9xxx: Add support for REPEAT_CHANGE_VALUE

Slimbus supports ability to write upto 16 bytes to the same register as
one transaction on the bus through REPEAT_CHANGE_VALUE slimbus message.
Add support to write codec register with multiple values using
REPEAT_CHANGE_VALUE. Not all sizes from 1 to 16 are supported by such a
message, add support in driver to be able to write all sizes from 1 to
16 by splitting the register writes of unsupported sizes into multiple
writes of supported sizes.

Change-Id: I33fdd983068bc10f65523b2a95f1d7741fa6c486
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>