OSDN Git Service

sagit-ice-cold/kernel_xiaomi_msm8998.git
8 years agoion: msm: fix Makefile dependencies
Jeremy Gebben [Wed, 10 Feb 2016 17:45:46 +0000 (10:45 -0700)]
ion: msm: fix Makefile dependencies

ion_cma_heap.o, ion_cma_secure_heap.o, and ion_system_secure_heap.o
all call functions which are only available if CONFIG_MSM_ION
is enabled.

Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
8 years agouapi: scsi: add missing header dependencies
Jeremy Gebben [Tue, 9 Feb 2016 23:20:33 +0000 (16:20 -0700)]
uapi: scsi: add missing header dependencies

Add #include dependencies to pick up definitions of __u32 and HZ.

Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
8 years agouapi: fix export of msm_ion.h
Jeremy Gebben [Tue, 9 Feb 2016 20:35:27 +0000 (13:35 -0700)]
uapi: fix export of msm_ion.h

Make this file be exported via symlink like the rest
of the android staging uapi headers.

Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
8 years agomsm: secure_buffer: fix stub functions
Jeremy Gebben [Wed, 10 Feb 2016 17:38:11 +0000 (10:38 -0700)]
msm: secure_buffer: fix stub functions

All of these need to be 'static inline' to avoid multiple
definition problems when MSM_SECURE_BUFFER=n.

Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
8 years agodefconfig: arm64: Add msmcortex defconfigs
Abhimanyu Kapur [Mon, 8 Feb 2016 22:20:50 +0000 (14:20 -0800)]
defconfig: arm64: Add msmcortex defconfigs

Add defconfig for supporting msmcobalt debug, perf
and other similar targets.

Change-Id: I3a55fea53cbfe65131fc4ccd505bc684cda9b2fa
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
8 years agosmp: Allow booting a specific subset of CPUs
Stepan Moskovchenko [Tue, 20 May 2014 02:07:33 +0000 (19:07 -0700)]
smp: Allow booting a specific subset of CPUs

In a heterogenous multiprocessor system, specifying the
'maxcpus' parameter on the kernel command line does not
provide sufficient control over which CPUs are brought
online at kernel boot time, since CPUs may have nonuniform
performance characteristics. Thus, we introduce a
'boot_cpus' command line argument, allowing the user to
explicitly specify the list of CPUs that shall be brought
online during kernel boot.

Change-Id: I5f119e23202660941fa7be8c4e6dd91a82365451
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
[abhimany: resolve trivial merge conflicts]
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
8 years agoarm64: Split out MSM8996 from generic ARCH_QCOM platform Kconfig
Abhimanyu Kapur [Mon, 8 Feb 2016 22:17:14 +0000 (14:17 -0800)]
arm64: Split out MSM8996 from generic ARCH_QCOM platform Kconfig

Add support for CONFIG_MSM89986 and split it out from generic
ARCH_QCOM platform.

Change-Id: Ibc287ffb76e5599ba63449534b264e4f31c98ec6
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
8 years agopinctrl: qcom: Snapshot pinctrl driver for msmcobalt
Abhimanyu Kapur [Mon, 8 Feb 2016 22:09:05 +0000 (14:09 -0800)]
pinctrl: qcom: Snapshot pinctrl driver for msmcobalt

Snapshot pinctrl driver and corresponding makefiles
and Kconfig from msm-3.18@b6a638f8795ee77ca
("Merge "msm: mdss: add support to send dcs cmds by
 left port only in video mode")

Change-Id: I129bb9bd4b7edd252550e6851332867be6fa0423
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
8 years agoARM: dts: qcom: Snapshot all device tree files for MSMCOBALT
Abhimanyu Kapur [Wed, 27 Jan 2016 22:02:10 +0000 (14:02 -0800)]
ARM: dts: qcom: Snapshot all device tree files for MSMCOBALT

Snapshot all device tree files from msm-3.18@b6a638f8795ee77ca
("Merge "msm: mdss: add support to send dcs cmds by
 left port only in video mode")

Change-Id: I631047dffa019c6d2ee731ead328d332f1c7f3b8
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
8 years agoRevert "defconfig: arm64: msm: Enable USB DWC3 and PHY drivers"
Rohit Vaswani [Tue, 9 Feb 2016 23:17:05 +0000 (15:17 -0800)]
Revert "defconfig: arm64: msm: Enable USB DWC3 and PHY drivers"

This reverts commit 52bfd76cadb4bcc4371ea83429d9de0dab981eb7.

8 years agodefconfig: enable subsystem restart, MSM_PIL_GENERIC and PIL_MSS_QDSP6V5
David Keitel [Thu, 4 Feb 2016 18:28:54 +0000 (10:28 -0800)]
defconfig: enable subsystem restart, MSM_PIL_GENERIC and PIL_MSS_QDSP6V5

Enable subsystem restart and relevant PIL drivers to allow secure
peripheral image loading and QDSP6V5 loading to work.

Change-Id: I899382d04e6a348cde2d46e9e0e6f3faadab2c5d
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
8 years agodefconfig: disable EFI
David Keitel [Thu, 4 Feb 2016 18:11:28 +0000 (10:11 -0800)]
defconfig: disable EFI

Change-Id: I26d6398478a8cbdcc56c93f501b70b9f9f2924e8
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
8 years agosoc: qcom: subsys-pil-tz: initialize DMA ops
David Keitel [Thu, 4 Feb 2016 18:03:38 +0000 (10:03 -0800)]
soc: qcom: subsys-pil-tz: initialize DMA ops

Initialize the DMA operations for the MDT data
DMA allocation.

Change-Id: If8eae5e91b4145be8d9e5eeeb28c14cda88e617f
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
8 years agosoc: qcom: add snapshot of PIL, SSR and SYSMON drivers/libraries
David Keitel [Wed, 3 Feb 2016 02:24:24 +0000 (18:24 -0800)]
soc: qcom: add snapshot of PIL, SSR and SYSMON drivers/libraries

This is a snapshot of PIL, SSR and SYSMON drivers and libraries as
of msm-3.18 commit
5cef33a285e91869cebe40a25e6294ae1e5fc9cc
(Merge "ASoC: msm: Update the AFE clock API support")

Change-Id: Ibebddee32b15fbcb5b18cceac43769d3309e609c
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
8 years agofirmware_class: Don't fail request_firmware if we're not using a buffer
Vikram Mulukutla [Thu, 14 May 2015 20:58:06 +0000 (13:58 -0700)]
firmware_class: Don't fail request_firmware if we're not using a buffer

A check that the intermediate firmware actually contains data
is performed before returning from request_firmware. Perform
this check only if we're actually using the intermediate
buffer.

Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
8 years agofirmware_class: Add an additional path to fw_path list
Deepak Katragadda [Thu, 8 Jan 2015 19:46:32 +0000 (11:46 -0800)]
firmware_class: Add an additional path to fw_path list

Add an additional path, /firmware/image to the list of fw paths
that request_firmware looks into for the firmware images.

Change-Id: I4b9164f222bf0a8546072de97838bf9d49dd8252
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>
8 years agofirmware_class: Change print levels for some warnings
Deepak Katragadda [Thu, 11 Dec 2014 21:25:54 +0000 (13:25 -0800)]
firmware_class: Change print levels for some warnings

Currently, when _request_firmware() fails to find the firmware
from the default /lib location, a couple of error messages are
printed denoting the same. Change the print level for these
messages from dev_warn to dev_dbg as it is fairly common to
have the user-space helper loading the firmware for us.

Change-Id: I5e06b3785f58e85eda45d32130b9acbc75cd2c0a
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>
[vmulukut: adjusted for upstream changes]
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
8 years agofirmware_class: Correct a null check in firmware_direct_read
Vikram Mulukutla [Fri, 8 Aug 2014 00:36:23 +0000 (17:36 -0700)]
firmware_class: Correct a null check in firmware_direct_read

Don't use the fw pointer before performing the null
check on it.

Change-Id: I303f71681647e2acb0b7e340b8f8580436cfb19d
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
8 years agofirmware_class: Include a size argument in unmap_fw_mem
Vikram Mulukutla [Tue, 31 Mar 2015 01:24:47 +0000 (18:24 -0700)]
firmware_class: Include a size argument in unmap_fw_mem

Some implementations may need to know the size of a
region allocated by map_fw_mem in the context of the
unmap_fw_mem callback. Add this as an argument to the
callback signature.

Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
8 years agofirmware_class: Allow private data in [unmap|map]_fw_mem
Vikram Mulukutla [Fri, 11 Apr 2014 03:23:30 +0000 (20:23 -0700)]
firmware_class: Allow private data in [unmap|map]_fw_mem

Some callers of request_firmware_direct may need additional
context to be able to map firmware memory. Allow private data
to be passed in with request_firmware_direct, and send this
data along with the [unmap|map]_fw_mem callbacks.

Change-Id: I05a15eb46cc663a4476b784e30e80182a28e10c3
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
[joshc: dropped PIL portions, fixed trivial conflict in firmware.h due
to API rename]
Signed-off-by: Josh Cartwright <joshc@codeaurora.org>
[vmulukut: adjusted for upstream merge conflicts]
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
8 years agofirmware_class: Introduce the request_firmware_direct API
Vikram Mulukutla [Mon, 5 Aug 2013 18:39:20 +0000 (11:39 -0700)]
firmware_class: Introduce the request_firmware_direct API

On devices with low memory, using request_firmware on rather
large firmware images results in a memory usage penalty that
might be unaffordable. Introduce a new API that allows the
firmware image to be directly loaded to a destination address
without using any intermediate buffer.

Change-Id: I51b55dd9044ea669e2126a3f908028850bf76325
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
[joshc: renamed request_firmware_direct to request_firmware_into_buf,
avoiding namespace conflict]
Signed-off-by: Josh Cartwright <joshc@codeaurora.org>
[vmulukut: upstream merge conflict fixups]
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
[dkeitel: upstream merge conflict fixups]
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
8 years agofirmware_class: Provide infrastructure to make fw caching optional
Vikram Mulukutla [Mon, 5 Aug 2013 18:17:29 +0000 (11:17 -0700)]
firmware_class: Provide infrastructure to make fw caching optional

Some low memory systems with complex peripherals cannot
afford to have the relatively large firmware images taking
up valuable memory during suspend and resume. Change the
internal implementation of firmware_class to disallow
caching based on a configurable option. In the near future,
variants of request_firmware will take advantage of this
configurability.

Change-Id: I44be7ce3b308b642fb018086def99fcb800a1109
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
[joshc: reworked to use opt_flags instead of 'nocache' bool in fw_desc]
Signed-off-by: Josh Cartwright <joshc@codeaurora.org>
[vmulukut: adjusted for upstream additions to opt_flags]
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
8 years agofirmware_class: Introduce a firmware descriptor structure
Vikram Mulukutla [Mon, 5 Aug 2013 17:38:35 +0000 (10:38 -0700)]
firmware_class: Introduce a firmware descriptor structure

Introduce a firmware descriptor structure that makes it
easier to pass around various configuration options in the
internal implementation of firmware_class.

Change-Id: I5c1da222bccd568fabb26da5baccaa4035331efd
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
[joshc: reworked to make use of upstream's opt_flags member]
Signed-off-by: Josh Cartwright <joshc@codeaurora.org>
[vmulukut: adjusted for upstream changes to opt_flags]
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
[dkeitel: resolved merge conflicts]
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
8 years agoof: platform: initialize of_reserved_mem
David Keitel [Thu, 4 Feb 2016 18:12:25 +0000 (10:12 -0800)]
of: platform: initialize of_reserved_mem

Initialize reserved memory as part of of_platform_device_create_pdata.

Change-Id: I6bb6ba8279af6771cb61087405cb915f4a0602b3
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
8 years agodma-mapping: fix merge conflict mistake
David Keitel [Thu, 4 Feb 2016 18:07:32 +0000 (10:07 -0800)]
dma-mapping: fix merge conflict mistake

As part of the 4.4 upgrade an incorrect merge
conflict resolution in dma-mapping caused the
function  __dma_alloc_coherent to not work correctly.

Fix this by changing correctly resolving the merge conflict
resolution.

Change-Id: I5b2411187768f2e3c4292a7c28cd742f5eb2dc54
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
8 years agodefconfig: enable MSM_PM for msm-perf defconfig
Mahesh Sivasubramanian [Mon, 1 Feb 2016 18:08:14 +0000 (11:08 -0700)]
defconfig: enable MSM_PM for msm-perf defconfig

Enable sleep driver for QCOM chipsets

Change-Id: I67244ff55690c164634e9233e2d0cec3388c5be8
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
8 years agodefconfig: Enable MPM for msm-perf defconfig
Mahesh Sivasubramanian [Mon, 25 Jan 2016 22:24:11 +0000 (15:24 -0700)]
defconfig: Enable MPM for msm-perf defconfig

Change-Id: I09313d7809ec939a9d0440d0ab30a5992f512b96

8 years agoirqchip: gic: Propagate CONFIG_PM changes to gic v3
Archana Sathyakumar [Fri, 13 Mar 2015 20:34:06 +0000 (14:34 -0600)]
irqchip: gic: Propagate CONFIG_PM changes to gic v3

Add suspend, idle power collapse callbacks to enable/disable interrupts.

Change-Id: I4b9b38b76d19423345f148054a2437d552299041
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Conflicts:
drivers/irqchip/irq-gic-v3.c

8 years agoirqchip: gic: Add arch extension to GIC v3
Archana Sathyakumar [Fri, 13 Mar 2015 20:32:17 +0000 (14:32 -0600)]
irqchip: gic: Add arch extension to GIC v3

Propagate platform arch extension to call into platform specific
callback functions for GIC operations.

Change-Id: Ief42e9812e0593572bbde0fbe5e641eb9b3f5412
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Conflicts:
drivers/irqchip/irq-gic-common.c
drivers/irqchip/irq-gic-common.h
drivers/irqchip/irq-gic-v3.c
drivers/irqchip/irq-gic.c

8 years agosoc: qcom: Use arch_counter_get_cntvct instead of arch_counter_get_cntpct
Mahesh Sivasubramanian [Fri, 5 Feb 2016 19:45:12 +0000 (12:45 -0700)]
soc: qcom: Use arch_counter_get_cntvct instead of arch_counter_get_cntpct

Kernel version 4.4 has deprecated the use of *pct versions for 64 bit
targets. Hence moving to vct as recommended.

Change-Id: Ibabf3eb28f58daccd58cde207262b34ed3b1c04f

Use vct instead of pct()

Change-Id: Ibabf3eb28f58daccd58cde207262b34ed3b1c04f
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
8 years agoarm64: psci: Support for OS initiated scheme
Mahesh Sivasubramanian [Thu, 23 Apr 2015 22:20:05 +0000 (16:20 -0600)]
arm64: psci: Support for OS initiated scheme

Existing PSCI implementation supports platform coordinated means of low
power modes where cluster low power modes are aggregated at the platform
level.  Adding support for OS initiated scheme, where is OS is responsible
for selecting cluster low power modes based on last man determination. With
OS initiated scheme, the OS can make better cluster decisions based on
wakeup times of CPUs within a cluster.

To this effect, in OS initiated schemes, the composite state ID is computed
by the idle driver before calling into the cpu_suspend API. The PSCI driver
is modified to use the composite ID to distinguish between retention and
non-retention states.

Change-Id: Iee5533676a28a8f6beb7942dcb908f2fa3518d78
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Conflicts:
arch/arm64/kernel/psci.c

8 years agoARM64: smp: Prevent cluster LPM modes when pending IPIs on cluster CPUs
Mahesh Sivasubramanian [Fri, 19 Sep 2014 02:33:55 +0000 (20:33 -0600)]
ARM64: smp: Prevent cluster LPM modes when pending IPIs on cluster CPUs

LPM modes can fail if there is a pending IPI interrupt at GIC CPU
interface. On some usecases frequent failure of LPM modes can
cause power and performance degradation. Hence, prevent cluster
low power modes when there is a pending IPI on cluster CPUs.

Change-Id: Id8a0ac24e4867ef824e0a6f11d989f1e1a2b0e93
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Conflicts:
arch/arm/kernel/smp.c
arch/arm64/kernel/smp.c

8 years agocpuidle: lpm-levels: Fix compilation issues
Mahesh Sivasubramanian [Tue, 2 Feb 2016 00:10:22 +0000 (17:10 -0700)]
cpuidle: lpm-levels: Fix compilation issues

Compile drivers/power/qcom based on CONFIG_ARCH_QCOM instead of
CONFIG_ARCH_MSM
Fix use of __get_cpu_var and convert to this__cpu_ptr

Change-Id: I7152d74f9d495f9ab7af0cfd2f3695c9461469fb

8 years agopower: soc: qcom: Remove non-PSCI related drivers
Mahesh Sivasubramanian [Tue, 9 Feb 2016 18:07:45 +0000 (11:07 -0700)]
power: soc: qcom: Remove non-PSCI related drivers

Only PSCI compatible targets are supported moving forward. Remove drivers
that are used in legacy power collapse support.

Change-Id: I022bef78433c9693d3cb8752091c2c0ed2e4e994
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
8 years agoregulator: Fix miscellaneous warnings in regulator driver
Mahesh Sivasubramanian [Tue, 2 Feb 2016 00:10:05 +0000 (17:10 -0700)]
regulator: Fix miscellaneous warnings in regulator driver

Fix compiler warnings in regulator code

Change-Id: I8670b5a9591727a8215c6bc56fcdb70e473dd9d8
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
8 years agolpm-levels: Do not disable non-sec interrupts in suspend
Murali Nalajala [Tue, 19 May 2015 17:26:11 +0000 (10:26 -0700)]
lpm-levels: Do not disable non-sec interrupts in suspend

When the system suspend is happening, last core disables
the non-sec interrupts at QGIC by setting the GRPEN1_EL1_NS
to ZERO. This makes core not seen any non-sec interrupts
and would result into system do not wake up from any of
interrupts. Do not touch GRPEN1_EL1_NS register while
system is going into suspend.

Change-Id: I7d6c5047fb4743df187fe49fba18b64db3179bc9
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Conflicts:
drivers/irqchip/irq-gic-common.h

8 years agocpuidle: lpm-levels: Fixes for clockevents_notify
Mahesh Sivasubramanian [Mon, 1 Feb 2016 18:14:55 +0000 (11:14 -0700)]
cpuidle: lpm-levels: Fixes for clockevents_notify

The use of clockevents_notify is deprcated and targeted APIs are used
instead of the clockevents_notify callbacks. Switch broadcast timer
notifications to tick_broadcast_enter and tick_broadcast_exit.

Change-Id: I3441873eb4009b105db04f4a18d28ae9ccd07e95

8 years agocpu_pm: Add level to the cluster pm notification
Murali Nalajala [Thu, 8 Jan 2015 03:36:57 +0000 (19:36 -0800)]
cpu_pm: Add level to the cluster pm notification

Cluster pm notifications without level information increases difficulty
and complexity for the registered drivers to figure out when the last
coherency level is going into power collapse.

Send notifications with level information that allows the registered
drivers to easily determine the cluster level that is going in/out of
power collapse.

There is an issue with this implementation. GIC driver saves and
restores the distributed registers as part of cluster notifications. On
newer platforms there are multiple cluster levels are defined (e.g l2,
cci etc). These cluster level notofications can happen independently.
On MSM platforms GIC is still active while the cluster sleeps in idle,
causing the GIC state to be overwritten with an incorrect previous state
of the interrupts. This leads to a system hang. Do not save and restore
on any L2 and higher cache coherency level sleep entry and exit.

Change-Id: I31918d6383f19e80fe3b064cfaf0b55e16b97eb6
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
8 years agoqcom: kconfig: Enable MSM_PM to enable QCOM sleep drivers
Mahesh Sivasubramanian [Mon, 1 Feb 2016 18:08:14 +0000 (11:08 -0700)]
qcom: kconfig: Enable MSM_PM to enable QCOM sleep drivers

Enable sleep driver for QCOM chipsets

Change-Id: I67244ff55690c164634e9233e2d0cec3388c5be8
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
8 years agosoc: qcom: idle: Snapshot of idle/sleep driver as of msm-3.18
Mahesh Sivasubramanian [Mon, 1 Feb 2016 17:40:26 +0000 (10:40 -0700)]
soc: qcom: idle: Snapshot of idle/sleep driver as of msm-3.18

This is a snapshot of the Sleep driver and realted functionality as of
e70ad0cd5efdd9dc91a77dcdac31d6132e1315c1 on msm-3.18 branch

Change-Id: I98fec26849898c5c66abbb1b094439780c23964d

8 years agosoc: qcom: mpm-of: Add gpio_arch_extn support
Mahesh Sivasubramanian [Thu, 28 Jan 2016 23:29:33 +0000 (16:29 -0700)]
soc: qcom: mpm-of: Add gpio_arch_extn support

To wake up from system sleep, the MPM driver needs to keep track of enabled
GPIO interrupts. Add gpio_arch_extn to support monitoring of GPIO interrupts

Change-Id: If97f566e11eaab452e4b55db1a05e5457f1a8d3f
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
8 years agoReverting "irqchip: gic: Drop support for gic_arch_extn"
Marc Zyngier [Wed, 22 Apr 2015 17:20:04 +0000 (18:20 +0100)]
Reverting "irqchip: gic: Drop support for gic_arch_extn"

MSM chipsets rely on arch_extn to get the necessary functionality. Add them
until a upstream solution  can be arrived at.

Change-Id: I773a3e82ca81b1c49cf2581f5288cacaeb6c6db0
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
8 years agoirqchip: msm: Add snaphot of msm irq driver
Abhimanyu Kapur [Mon, 30 Mar 2015 18:55:03 +0000 (11:55 -0700)]
irqchip: msm: Add snaphot of msm irq driver

Snapshot the msm irq driver as of msm-3.14 commit:

3bc54cf86bdc7affa7cd4bf7faa3c57fe8f8819d (Merge "msm:
camera: Add dummy sub module in sensor pipeline")

Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
Conflicts:
drivers/irqchip/Kconfig
drivers/irqchip/Makefile

Change-Id: Idf5284906af960fe03dcf881df1b57149c8e6ad8

8 years agodefconfg: Enable MPM for msm defconfig
Mahesh Sivasubramanian [Mon, 25 Jan 2016 22:24:11 +0000 (15:24 -0700)]
defconfg: Enable MPM for msm defconfig

Change-Id: I09313d7809ec939a9d0440d0ab30a5992f512b96

8 years agosoc: qcom: Add snapshot of MPM driver
Mahesh Sivasubramanian [Mon, 25 Jan 2016 22:15:10 +0000 (15:15 -0700)]
soc: qcom: Add snapshot of MPM driver

This snapshot is taken as of msm-3.18 commit e70ad0cd (Promotion of
kernel.lnx.3.18-151201.)

Change-Id: I93b163cdd379e3cb9601512d2a06424987b5a132
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
8 years agodefconfig: arm64: msm: Enable USB DWC3 and PHY drivers
Jack Pham [Tue, 2 Feb 2016 21:40:19 +0000 (13:40 -0800)]
defconfig: arm64: msm: Enable USB DWC3 and PHY drivers

Enable DWC3, QUSB and QMP PHY drivers to support the USB
controller hardware. Also enable XHCI_HCD for USB host mode.

Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: host: Call arch_setup_dma_ops() before setting DMA mask
Jack Pham [Fri, 5 Feb 2016 06:24:55 +0000 (22:24 -0800)]
usb: dwc3: host: Call arch_setup_dma_ops() before setting DMA mask

For host mode operation, the DWC3 driver instantiates an XHCI
device directly using platform_device_alloc()/_add() instead of
using typical device population methods (i.e. DT or ACPI).
In the latter cases, there is additional setup involved beyond
the allocation itself, not the least of which is DMA setup.

On ARM64 the recent commit 1dccb598df54 ("arm64: simplify
dma_get_ops") sets the default DMA operations to dummy ops. This
causes a regression as this directly created XHCI platform device
now fails probe when the call to dma_set_mask_and_coherent() is
unable to proceed due to dma_supported() returning false.

Since we know that the XHCI device is a child of DWC3 and hence
is also DMA-capable, fix this in the DWC3 host driver by simply
calling arch_setup_dma_ops() after allocating the platform_device.

Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agodwc3: gadget: Ignore suspend event if USB speed is unknown
Mayank Rana [Thu, 28 Aug 2014 23:47:51 +0000 (16:47 -0700)]
dwc3: gadget: Ignore suspend event if USB speed is unknown

In some of host machine reboot usecases, it has been found that
multiple suspend events are being received before usb device is
being enumerated with host including receiving suspend before
BUS RESET. This suspend event is being seen due to not host
initiated suspend but due to LINE state at that point and may
put USB Host and Device out of sync where host may not send any
more BUS RESET which would cause USB device enumeration as unknown
device with host machine. Fix this issue by honouring suspend
event only when USB enumeration speed is known.

CRs-Fixed: 717151
Change-Id: I201f106d1be71716eaa7a6246d2187889ea53a9c
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agousb: dwc3: Add changes to support dual-role switching
Jack Pham [Tue, 2 Feb 2016 20:57:37 +0000 (12:57 -0800)]
usb: dwc3: Add changes to support dual-role switching

This patch is a squash of several commits from msm-3.18 that
add support for dual-role switching (formerly known as "OTG")
to the DWC3 and XHCI platform drivers.

Based on the following commits:

usb: dwc3: Introduce OTG driver for dwc3
usb: dwc3-msm: Add support for LPM on cable disconnect
DWC3: Enable XHCI host in OTG mode
USB: dwc3: Add support for host bus suspend
usb: dwc3 / xhci_plat: Call xhci_suspend/resume when entering/exiting LPM
USB: dwc3: gadget: Implement gadget_vbus_draw() API
USB: gadget: dwc3: Fix composition switch issue during cable disconnect
usb: dwc3: notify gadget disconnect upon VBUS low
usb: dwc3: msm: Remove last of dwc3_otg
dwc3: Reset USB controller/PHY after psy connect indication at bootup
dwc3: Use otg_sm_work state machine for host and device only mode

Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: Add support for POR upon composition switch
Hemant Kumar [Thu, 27 Aug 2015 00:18:36 +0000 (17:18 -0700)]
usb: dwc3: Add support for POR upon composition switch

Composition switch to GSI transport based composition from
another GSI transport based composition requires power on
reset of USB controller to synchronize operation with USB
wrapper for GSI. Specifically GSI_EN bit cannot be
cleared without performing usb controller reset. Hence
introduce gadget restart operation to simulate vbus off
and vbus on and perform  this operation from gsi bind
config.

Change-Id: Ie4695807c73c2d14c0d9e17c486f34a90fd93ddb
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
8 years agousb: dwc3: gadget: Increase the link state change timeout value
Hemant Kumar [Sat, 7 Mar 2015 01:30:03 +0000 (17:30 -0800)]
usb: dwc3: gadget: Increase the link state change timeout value

After the device  remote wake up some USB hosts are driving bus
resume for longer than 3 seconds. As a result link state change does
not happen within 3 seconds and remote wake up fails. In worst case
it is observed that usb host is driving bus resume for 8 seconds.
Hence increase the timeout value to 16 seconds.

CRs-Fixed: 803183
Change-Id: I1cbb29ccd2b4e264c032d7237efcfd87cef71942
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
8 years agousb: dwc3: gadget: Avoid unclocked access due to pm_runtime_get failure
Tarun Gupta [Wed, 10 Jun 2015 13:58:49 +0000 (19:28 +0530)]
usb: dwc3: gadget: Avoid unclocked access due to pm_runtime_get failure

If remote wakeup request is received during system resume where
resume_early is still processing, pm_runtime_get_sync returns -EACCES error
as pm_runtime framework is disabled between late_suspend and early_resume.
Due to failure of this API controller did not exit LPM. This leads to
unclocked access of registers as part of remote wakeup processing causing
target to crash.

Fix this by checking for return value of pm_runtime_get_sync, and queuing
dwc3_gadget_wakeup_work again with intermediate delay of 100ms for maximum
of 20 times.

Change-Id: I8e2215ef9ee708e86356622e85fd2f23a18f7944
Signed-off-by: Tarun Gupta <tarung@codeaurora.org>
8 years agousb: dwc3: gadget: Fix PM runtime get/put in case of remote wakeup
Azhar Shaikh [Mon, 27 Apr 2015 22:09:23 +0000 (15:09 -0700)]
usb: dwc3: gadget: Fix PM runtime get/put in case of remote wakeup

In case of remote wakeup interrupt, dwc3_gadget_wakeup_work()
does a pm_runtime_get_sync() and dwc3_gadget_wakeup_interrupt()
does not notify OTG state machine about this state change.
Due to which OTG will be still in B_SUSPEND state.
Now when bus suspend happens, since OTG state machine is already in
B_SUSPEND state, it does not do a pm_runtime_put_autosuspend() and the
count is not decremented.
To fix, this do an unconditional pm_runtime_get_sync() and
pm_runtime_put_noidle() in dwc3_gadget_wakeup_work() to avoid any
unclocked register access. In dwc3_gadget_wakeup_interrupt() kick in
SM machine in all cases and handle the remote wakeup same as host
initiated resume, by clearing the B_SUSPEND bit so that OTG state machine
moves to B_PERIPHERAL state.

CRs-fixed: 829205
Change-Id: I270df517d5dd58fe28bf0087e0ba951c4e9e15ba
Signed-off-by: Azhar Shaikh <azhars@codeaurora.org>
8 years agodwc3: gadget: Replace polling mechnism to go into U0 state
Mayank Rana [Tue, 25 Nov 2014 23:29:58 +0000 (15:29 -0800)]
dwc3: gadget: Replace polling mechnism to go into U0 state

Moving into U0 state is being confirmed by polling for 100ms after
performing remote wakeup from device. In some of cases where host is
taking more time to respond, remote wakeup is failing. Also USB
specification does not define any limit for the host response time.
Hence this change replaces polling mechnism by using LINK status
change event notification with core and increase host response time
from 100ms to 3 seconds. It also makes sure that composite_resume()
is being called after remote wakeup is completed succesfully.

It removes some of flag used to avoid race between bus suspend/resume
and fuction suspend/resume as those are serialize and not required
anymore.

CRs-Fixed: 712681
Change-Id: I71285daf117282c738e139e9a05ead6ef16dd202
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agousb: dwc3: gadget: Ignore L1 RESUME events
Jack Pham [Sat, 25 Oct 2014 02:18:58 +0000 (19:18 -0700)]
usb: dwc3: gadget: Ignore L1 RESUME events

Events may get generated for Link Power Management L1
Suspend and Resume. The suspend case currently ignores
L1 and only proceeds to call the gadget driver suspend
routines if it is for L2/U3 entry. However, the resume
callback doesn't make this distinction, which will
result in the gadget layer resume getting called for
which there had not been a previous suspend.

Instead of relying on reading the DWC3_DSTS register for
U0 and U3 state, update dwc->link_state directly on receiving
reset/wakeup and suspend/disconnect interrupts respectively.

Change-Id: Ifaa71d2e85bd797154f368e7623bc8ff94b6a727
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
[jackp@codeaurora.org: Squashed with "usb: dwc3: gadget: Update
 link_state based on receiving interrupt" and "dwc3: gadget: Update
 link_state flag on receiving wakeup_interrupt" ]
Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: Allow controller to enter LPM in bus suspend
Jack Pham [Sat, 11 Apr 2015 07:56:27 +0000 (00:56 -0700)]
usb: dwc3: Allow controller to enter LPM in bus suspend

Add a DT property that decides whether to allow controller
low power mode upon bus suspend, which will be invoked by
the OTG state machine.

It is also required to take the core out of LPM in case
ep_queue is called by the upper layers. In this case,
remote wakeup sequence will be initiated once the core
is out of LPM.

[jackp@codeaurora.org: Squashed with dwc3 changes from
 "usb: dwc3: Add new OTG state OTG_STATE_B_SUSPENDED"]
Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3-msm: Remove POST_INIT notification
Jack Pham [Tue, 2 Feb 2016 18:57:06 +0000 (10:57 -0800)]
usb: dwc3-msm: Remove POST_INIT notification

This notification for this event is no longer used, so remove it.

Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: Add support to suspend SS phy
Jack Pham [Tue, 2 Feb 2016 07:48:15 +0000 (23:48 -0800)]
usb: dwc3: Add support to suspend SS phy

Upstream commit 636e2a2caeafcb1b55b6799b29fe436039819eb9
(usb: dwc3: gadget: drop dwc3 manual phy control) removed the
support to suspend the PHYs since the recent controller versions
can do that automatically.
But MSM targets, still do not have the latest controller and hence
adding back the functionality to suspend/resume SS phy.

Change-Id: I02a7ae8daf194a645f3582480f5a6b7d504b32ec
Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: Add support for GSI operations to gadget framework
Hemant Kumar [Sat, 10 Oct 2015 02:36:21 +0000 (19:36 -0700)]
usb: dwc3: Add support for GSI operations to gadget framework

Targets supporting h/w accelerated path over GSI require
GSI specific configuration of USB controller.

Add support to enable h/w accelerated path to IPA.
Include operations to configure USB endpoints as
GSI capable, allocate TRBs that are associated with
GSI capable endpoints, perform operations on these
endpoints, and enable the GSI wrapper in DWC3 controller.
This allows a function driver to use GSI based h/w
accelerated data path.

Change-Id: I62688c70a04b1fdab3e522e0af759ebab69d92d7
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
8 years agoRevert "usb: dwc3: Reset the transfer resource index on SET_INTERFACE"
Azhar Shaikh [Fri, 18 Dec 2015 20:07:17 +0000 (12:07 -0800)]
Revert "usb: dwc3: Reset the transfer resource index on SET_INTERFACE"

commit a0c760181ca874 ("usb: dwc3: Reset the transfer resource index
on SET_INTERFACE") was resetting the start_config_issued flag on
receiving SetInterface request. But in cases where transfer resource
index is shared between two endpoints and if both are trying to do a
transfer then transfer on one of the endpoints will fail, since the
transfer resource index will be acquired by the first endpoint
and when the second endpoint tries to get the same transfer resource
index, it will fail and hence STARTTRANSFER command also fails on second
endpoint.
Reverting this change ensures endpoints get allocated with unique
transfer resource index.

CRs-fixed: 953585
Change-Id: I7800356e455900cc39b9463366275c68db777199
Signed-off-by: Azhar Shaikh <azhars@codeaurora.org>
8 years agousb: dwc3: Offload IRQ handling to softirq context
Azhar Shaikh [Wed, 5 Aug 2015 01:45:57 +0000 (18:45 -0700)]
usb: dwc3: Offload IRQ handling to softirq context

Move interrupt handling from threaded IRQ context to a tasklet.
This may help in reducing latencies associated with starvation
caused by high priority softirq over threaded USB IRQ.

Change-Id: I2f988be9c484a6ee59236d9dfd7f06f07414ee96
Signed-off-by: Azhar Shaikh <azhars@codeaurora.org>
8 years agousb: dwc3: Don't check usb isochronous endpoint check for ep0
Mayank Rana [Wed, 28 Oct 2015 03:28:51 +0000 (20:28 -0700)]
usb: dwc3: Don't check usb isochronous endpoint check for ep0

Commit 5ad02fb813a9 ("usb: dwc3: gadget: move isoc endpoint check
to unlocked set_halt") moved usb isochronous endpoint check form
dwc3_gadget_ep_set_halt() to __dwc3_gadget_ep_set_halt().
dwc3_gadget_ep_set_halt() API is being called explicitly by USB
function driver to stalls USB endpoints whereas
__dwc3_gadget_ep_set_halt() API is also being called to stall ep0
on receiving invalid setup packet or not able to queue response
to setup packet. It is not supposed to have any descriptors with
ep0 early stage of enumeration process. Hence revert change which
makes sure to check usb endpoint type against isochronous before
halting endpoint with dwc3_gadget_ep_set_halt() instead of
__dwc3_gadget_ep_set_halt().

Change-Id: I24b3e78613bf89340c812e353dafaf384ac4a057
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agousb: dwc3: Clear pending events when it is bigger than event buffer size
Mayank Rana [Fri, 6 Nov 2015 23:11:46 +0000 (15:11 -0800)]
usb: dwc3: Clear pending events when it is bigger than event buffer size

Currently there exists a race condition between dwc3_gadget_run_stop()
and dwc3 gadget interrupt handling. run_stop() could get cleared and set
again in between hard IRQ and threaded IRQ contexts, the DWC3_GEVNTCOUNT
could first get set to 0, and then written again in the threaded handler
with a non-zero value. Writing back to this register will cause hardware
to decrement the value, and since it is 0 will result in a high unsigned
value (~65k).

To handle this condition mark received events as processed and return
IRQ_HANDLED if events count is bigger than event buffer size. Note that
the root cause of this condition will be addressed in another patch that
prevents the race by synchronizing the hard and threaded interrupt handlers
with dwc3_gadget_run_stop() getting called asynchronously.

Change-Id: I4d6ade8243867885f26876a5233a8456a7e8bf42
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agousb: dwc3: Disable ep0 and interrupts when clearing run/stop
Jack Pham [Wed, 21 Oct 2015 19:50:15 +0000 (12:50 -0700)]
usb: dwc3: Disable ep0 and interrupts when clearing run/stop

In dwc3_gadget_run_stop() when clearing the run/stop bit, ensure
that IRQs are masked and the ep0 in and out endpoints are disabled.
In case pullups are removed while a control transfer is in progress,
this makes sure that the control endpoints are properly cleaned up.
If and when run/stop is set again, the function already re-enables
the IRQ and ep0 when calling dwc3_gadget_restart(). While at it,
memset() the event buffers to clear stale contents when
reinitializing them in dwc3_event_buffers_setup().

Also, since calling dwc3_gadget_disable_irq() only masks the
interrupts at the controller layer, it might not catch instances
where an IRQ itself may have already been asserted but does not
arrive at the handler until after the pullups are removed. Add a
check to dwc3_interrupt() to catch this case as well.

Change-Id: Ie58979fe4b229240231760652189338ec5343a2d
Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: Replace WARN_ON() by WARN_ON_ONCE() and logging with buffer
Mayank Rana [Fri, 11 Sep 2015 17:47:36 +0000 (10:47 -0700)]
usb: dwc3: Replace WARN_ON() by WARN_ON_ONCE() and logging with buffer

In some of cases when ep0 operations are fails, WARN_ON is called from
interrupt context. This may lead to watchdog bark if repeated WARN_ON
condition occurs. Hence replace usage of WARN_ON() by WARN_ON_ONCE() and
logging errror as part of debug buffer.

CRs-Fixed: 907077
Change-Id: I40de055b1e8d610c43c7fff32cd904c43b9bec00
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agousb: dwc3: Allocate TRB pool upon enabling endpoint
Hemant Kumar [Tue, 16 Jun 2015 21:43:51 +0000 (14:43 -0700)]
usb: dwc3: Allocate TRB pool upon enabling endpoint

Currently gadget driver is by default allocating dma TRB
pool per endpoint for 30 endpoints upon driver probe.
Optimize this by allocating dma memory only for enabled
endpoints.

Change-Id: I378a42d0b84fa43f7c20cd025cd9361c467cb41b
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
8 years agodwc3: gadget: Use default TX FIFO size as 1024 bytes with each IN eps
Mayank Rana [Mon, 29 Jun 2015 19:05:45 +0000 (12:05 -0700)]
dwc3: gadget: Use default TX FIFO size as 1024 bytes with each IN eps

Commit d8a39efaa477 ("dwc3: gadget: Improve TX FIFO resize functionality")
is considering USB enumerated speed to allocate TX FIFO size for each IN
endpoints. This change simplifies this by using 1024 bytes as default
TXFIFO size with each IN endpoints.

Change-Id: I55b5886c824d9b689ac8496f50f6e0e784afae98
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agodwc3: gadget: Avoid processing of trb if HWO bit is set
Mayank Rana [Sun, 28 Jun 2015 01:39:18 +0000 (18:39 -0700)]
dwc3: gadget:  Avoid processing of trb if HWO bit is set

HWO bit signifies that TRB is still pending with hardware. Hence
avoid processing of TRB if HWO bit is set.

Change-Id: I6d4068eb9e6934f68e7b6204cac8f6f3266dabf4
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agodwc3: Increase event buffer size to 8KB from 256 bytes
Mayank Rana [Mon, 22 Jun 2015 21:57:26 +0000 (14:57 -0700)]
dwc3: Increase event buffer size to 8KB from 256 bytes

Commit 5da93478251c ("usb: dwc3: decrease event buffer size") has
decreased controller's event buffer size to 256 bytes which results
into multiple overflow events. Receiving of overflow events suggests
that software is not able to process received events fast enough
which results into losing of those events. Fix this issue by
increasing event buffer size to 8KB.

Change-Id: I37f6203f0b6d87098d57b2ce0ba8a3a0b8ef5bd2
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agodwc3: gadget: Improve TX FIFO resize functionality
Mayank Rana [Tue, 2 Jun 2015 02:45:17 +0000 (19:45 -0700)]
dwc3: gadget: Improve TX FIFO resize functionality

This change considers USB device speed to set max_packet size
instead of provided max_packet value from USB function driver.
It doesn't resize ep0IN TxFIFO, and starts with ep1IN TxFIFO only.

Change-Id: Ifce63f5a8570f79bad1e5d3ae6f5d580c34046b5
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agodwc3: gadget: Initialized USB TRBs pool memory with zero
Mayank Rana [Tue, 19 May 2015 01:27:53 +0000 (18:27 -0700)]
dwc3: gadget: Initialized USB TRBs pool memory with zero

dma_coherent_alloc() API doesn't guaranteed that allocated memory
is initialized with zero. It is observed in some cases where there
is stale data seen with allocated memory for TRB pool and providing
this TRB with USB controller results into different memory access
issues. Fix this issue by using dma_zalloc_coherent() API which
allocates memory and initialized it with zero.

Change-Id: I160e319aace262958a11ba5196f53ec21b98977f
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agodrivers: usb: dwc3: Add XMIT_DEV command
Ido Shayevitz [Thu, 14 Aug 2014 07:20:49 +0000 (10:20 +0300)]
drivers: usb: dwc3: Add XMIT_DEV command

Starting with synopsis version 220A the command to wake up the
host changed from 0x3 to 0x7. The code is fixed accordingly.
The problem that was seen is that upon MBIM function
suspend, a remote wakeup from the IPA side wouldn't
wake up the host, and at some point a stall in the IPA would be
seen.

CRs-fixed: 695414
Change-Id: I6ef5c649f263f388a1cc92a3db71c14c741b5b71
Signed-off-by: Lena Salman <esalman@codeaurora.org>
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
8 years agousb: dwc3-msm: Bring controller out of LPM early upon system resume
Hemant Kumar [Sun, 29 Mar 2015 07:37:04 +0000 (00:37 -0700)]
usb: dwc3-msm: Bring controller out of LPM early upon system resume

In case of host initiated usb bus resume upon system suspend controller
exits from LPM as part of dwc3 PM resume. Since call to dwc3 PM resume
from PM framework involves latency due to which usb device misses the
timeline of response for bus resume. This results into host issuing warm
reset. Hence bring controller out of LPM in power event irq thread context.
Set IRQF_EARLY_RESUME for power event irq which reduces irq level latency
by enabling this irq early during system resume. Also, save power event
irq time stamp to track latency between hard irq and irq thread.

CRs-Fixed: 804476
Change-Id: Ib5470c6046ffbfff55b89e717f040bd6435454da
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
8 years agodwc3: gadget: Ignore suspend event if USB is not into CONFIGURED state
Mayank Rana [Fri, 29 Aug 2014 21:36:05 +0000 (14:36 -0700)]
dwc3: gadget: Ignore suspend event if USB is not into CONFIGURED state

For reboot usecase with some of host machine, it has been observed that
Suspend event is being received in between USB enumeration process which
is highly unlikely case. Although due to this event, device side USB goes
into suspend state which cause USB device enumerates as unknown device
with host machine. Fix this issue by ignoring suspend event until USB
enumeration process is not being completed i.e. device side USB is not
reach into CONFIGURED state.

Add check for CONFIGURED state with controller suspend routine as well
to make sure that if this routine finds controller into L2 state before
it performs LPM functionality, it confirms that state of USB as
CONFIGURED.

CRs-Fixed: 717151
Change-Id: I86925f22edf94c526a3b7504333501b6e27412d7
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agousb: dwc3: core: Disable internal clock gating conditionally
Mayank Rana [Wed, 10 Jun 2015 18:43:09 +0000 (11:43 -0700)]
usb: dwc3: core: Disable internal clock gating conditionally

Currently USB DWC3 controller's internal clock gating is disabled
unconditionally. In few platform, it is possible to enable internal
clock gating with controller. Hence this change adds support to
disable this functionality conditionally using "snps,disable-clk-gating"
device tree property. With this change USB controller's internal clock
gating is enabled by default.

CRs-Fixed: 851877
Change-Id: I17d43a23d3bff0cb516b952c35c4a13af53f7777
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agodwc3: gadget: Add NULL check against endpoint's desc in set_halt()
Mayank Rana [Tue, 28 Apr 2015 17:39:56 +0000 (10:39 -0700)]
dwc3: gadget: Add NULL check against endpoint's desc in set_halt()

In few instances, dwc3_gadget_ep_set_halt() API is called after USB
endpoint is disabled which results into device crash with NULL pointer
dereference. USB endpoint's descriptors are set to NULL as part of USB
endpoint disable functionality. Hence fix this issue by adding NULL
pointer check against endpoint's descriptor.

CRs-Fixed: 829034
Change-Id: I2e1f67571ed202fab21655bd8f13fc54706419a7
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agousb: dwc3: Ignore multiple U3/L2 suspend events
Jack Pham [Tue, 31 Mar 2015 19:27:43 +0000 (12:27 -0700)]
usb: dwc3: Ignore multiple U3/L2 suspend events

The controller may sometimes generate back-to-back suspend
interrupt events. Ignore the repeated events to avoid calling
the gadget driver's suspend callback multiple times.

Change-Id: I284b461adeab5911388efd8bb7ecbf39a85c86ca
Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: gadget: Keep track of IRQ timing statistics
Jack Pham [Thu, 16 Oct 2014 01:23:37 +0000 (18:23 -0700)]
usb: dwc3: gadget: Keep track of IRQ timing statistics

It may be useful to debug how much time is spent in the
DWC3 hard IRQ context. Add low-overhead statistics counters
which keep a histogram of the last 10 interrupts' time of
occurence, time spent, and number of events read (which will
get processed in the bottom half handler).

Change-Id: I466144d8141f4236b9fb834dded93225b56d0422
Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agoDWC3: gadget: Report error if RX buffer not aligned to EP's MTU
Manu Gautam [Fri, 5 Oct 2012 07:46:00 +0000 (13:16 +0530)]
DWC3: gadget: Report error if RX buffer not aligned to EP's MTU

Synopsys USB3 Controller (DWC3) has a restriction where size
of OUT requests (TRB) queued to the controller must be aligned
with the endpoint's max packet size. Hence, report error in case
function driver tries to queue an unaligned request.

Change-Id: Id5f4a0ff9d2f9c55bba936d683608c524eadd260
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
8 years agousb: dwc3: Fall back to high speed when SSPHY fails
Mayank Rana [Wed, 11 Feb 2015 00:51:10 +0000 (16:51 -0800)]
usb: dwc3: Fall back to high speed when SSPHY fails

In some cases, it has been observed that SSPHY fails to initialized.
This change detects this condition and configures controller to work
into high speed mode only.

Change-Id: I50c4041d8572d0cdc4535812eebd10fc18b78e98
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agousb: dwc3: gadget: Fix calculation of request.actual for SG
Jack Pham [Sat, 7 Mar 2015 01:58:21 +0000 (17:58 -0800)]
usb: dwc3: gadget: Fix calculation of request.actual for SG

When a request completes, cleanup_done_trbs() tries to calculate
request.actual by subtracting the TRB remainder from the original
request.length, but does not account for scatter-gather requests
that queued multiple TRBs. In this case, the request.length field
may be used by the function to keep track of the aggregate length
of all the provided SG entries, and thus will produce an incorrect
request.actual. Instead, for scatter-gather, to find the pre-transfer
buffer length of each TRB, get the length field of each SG entry.
Then the number of bytes transfered can be correctly determined as
the difference between that and the bytes remaining in the TRB.

Change-Id: I4c197462ce5b804c9d684240e95c35b532976220
Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: Do not call WARN_ON_ONCE from interrupt context
Hemant Kumar [Fri, 31 Oct 2014 21:04:04 +0000 (14:04 -0700)]
usb: dwc3: Do not call WARN_ON_ONCE from interrupt context

Gadget driver calls WARN_ON_ONCE in some of the APIs which
are called from interrupt context. This may lead to watchdog
bark if repeated WARN_ON_ONCE condition occurs. Hence print
error message and/or log it in debug buffer.

CRs-Fixed: 747698
Change-Id: Ieecd6342135e7d2bad36c82a12958b78054150db
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
8 years agousb: dwc3: gadget: Resolve recursive spinlock during remote wakeup
Jack Pham [Fri, 29 Jan 2016 19:46:05 +0000 (11:46 -0800)]
usb: dwc3: gadget: Resolve recursive spinlock during remote wakeup

When a USB function wishes to send new data during USB suspend state, it
needs to issue USB remote wakeup and send a function wakeup notification
after then. This scenario leads to recursive spin locking inside the
_usb_func_wakeup() function, because this function gets called recursively.
This function issues remote wakeup, which internally calls the resume
interrupt callback, which calls the _usb_func_wakeup() function again.
This issue is resolved by performing the remote wakeup in a deferred work
context, and this splits the recursion loop.

CRs-fixed: 700667
Change-Id: I59c8efde098781587d29f08cd60e4aa3521949d8
Signed-off-by: Danny Segal <dsegal@codeaurora.org>
8 years agousb: dwc3: gadget: Prevent tx fifo resize before set config
Hemant Kumar [Thu, 30 Oct 2014 18:43:35 +0000 (11:43 -0700)]
usb: dwc3: gadget: Prevent tx fifo resize before set config

If device took longer than expected time queuing zlp in status
stage host issues bus reset. As a result tx fifio resize happens
at status stage of first control transfer after bus reset. This
causes null pointer dereference for config pointer as device is
not in configured state yet. Hence clear the resize_fifos flag
upon bus reset to avoid this situation. Also add NULL check in
dwc3_gadget_resize_tx_fifos().

CRs-Fixed: 747688
Change-Id: Icd50eaa15f75c1b0bd7e2f8db5550ad54af47ef8
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
8 years agodwc3: gadget: Clear per endpoint ring buffer when disabling endpoint
Mayank Rana [Wed, 14 Jan 2015 00:55:59 +0000 (16:55 -0800)]
dwc3: gadget: Clear per endpoint ring buffer when disabling endpoint

Current code is not clearing ring buffer once it is being initialized.
Issue is seen where xferinprogress interrupt is received with
isochronous endpoint due to stale TRB (for isochronous endpoint we
are using LINK TRB), we enqueue new request buffer using update
transfer command. If stale TRB is having HWO bit being set, controller
is trying to execute that particular TRB which results into error on
bus as that request buffer is already being freed or used by other
subsystem. Fix this issue by clearing per endpoint ring buffer when
disabling endpoint.

CRs-Fixed: 782340
Change-Id: I46e6a46400367d6ebf55bdb445a3330c0a4d77e1
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agoUSB: dwc3: Fix issues in isochronous endpoint handling
Vijayavardhan Vennapusa [Wed, 30 Jan 2013 12:05:45 +0000 (17:35 +0530)]
USB: dwc3: Fix issues in isochronous endpoint handling

If there are no requests queued by function driver when
XFRNRDY interrupt is recieved, pending flag will be set.
Then if function driver queues request, don't queue ENDTXFR
command and wait for XFRNRDY interrupt.

START TRANSFER command will fail if the interval for which
requests are being queued is already expired. Handle this
case by queueing ENDXFER command and waiting till recieves
XFRNRDY interrupt.

Change-Id: I9498be3967e0f80b05cf0830affe5463f07e2976
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: Add error print messages
Mayank Rana [Tue, 8 Jul 2014 00:07:16 +0000 (17:07 -0700)]
usb: dwc3: Add error print messages

There is a possible race that arises when gadget events are processed
before the resume routine has disabled the USB2 PHY autosuspend. Some
of the gadget events issue endpoint commands which may time out since
the PHY is still autosuspended. Add error messages to help debug
these failurs.

Signed-off-by: Mayank Rana <mrana@codeaurora.org>
8 years agousb: dwc3: Adjust TX FIFO allocation
Jack Pham [Tue, 21 Apr 2015 05:49:35 +0000 (22:49 -0700)]
usb: dwc3: Adjust TX FIFO allocation

Optimize the dwc3_gadget_resize_tx_fifos() function to better
allocate the per-endpoint FIFOs depending on a number of factors:

- super- or non-super speed
- bulk/isoc with bursting
- reduced RAM (when QDSS uses some internal RAM)
- endpoint enabled in composition

Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc: Fix function wakeup during suspend on SW path
Danny Segal [Tue, 17 Jun 2014 12:22:45 +0000 (15:22 +0300)]
usb: dwc: Fix function wakeup during suspend on SW path

When the SW wants to start USB traffic during USB bus suspend state, it
needs to issue remote-wakeup signaling to the USB host before sending the
function wakeup notification. This patch changes the function wakeup
sending notification function to check whenter the USB bus is suspended
and issue remote-wakeup if needed.

CRs-Fixed: 678203
Change-Id: I1b09e7763c821a0a0e62095b4dc1c8621a2316b3
Signed-off-by: Danny Segal <dsegal@codeaurora.org>
8 years agogadget: dwc: Support remote wakeup bit in GET_STATUS command in HS-USB mode
Danny Segal [Tue, 27 May 2014 09:22:38 +0000 (12:22 +0300)]
gadget: dwc: Support remote wakeup bit in GET_STATUS command in HS-USB mode

In High-Speed mode, the remote wakeup feature is enabled by a SET_FEATURE
command sent from the host. This patch adds the logic reflect this
configuration in the device GET_STATUS command response.

Change-Id: I0c934d0330d2580f15b1307005dde7b4b7874a7d
Signed-off-by: Danny Segal <dsegal@codeaurora.org>
8 years agousb: dwc: add support for super-speed function suspend
Danny Segal [Thu, 22 May 2014 13:11:58 +0000 (16:11 +0300)]
usb: dwc: add support for super-speed function suspend

The USB 3.0 specification defines a new 'Function Suspend' feature.
This feature enables the USB host to put inactive composite device
functions in a suspended state even when the device itself is not
suspended.
This patch extends the existing framework of USB dwc driver
to properly support the 'Function Resume' and 'Function Remote Wakeup'
related features.

Change-Id: If7bbfa7d6a4ff70d4b44ede5fc258370b890df47
Signed-off-by: Danny Segal <dsegal@codeaurora.org>
8 years agousb: gadget: Add udc_priv member to struct usb_request
Jack Pham [Wed, 10 Sep 2014 09:22:17 +0000 (02:22 -0700)]
usb: gadget: Add udc_priv member to struct usb_request

This member is used to store additional private flags
for BAM-enabled functions to pass information to the UDC.

Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: gadget: allow running wakeup in delayed context
Bar Weiner [Tue, 13 May 2014 12:45:00 +0000 (15:45 +0300)]
usb: dwc3: gadget: allow running wakeup in delayed context

Adding the option of running the gadget wakeup function
from the context in which it is called, or delaying it - in case
it is called from an atomic context. This is required in order
to support a case where the gadget is in lpm and the wakeup
would result in a queue to the low-powered hardware.

Change-Id: I09fc60e75c79202c97251146aab1539de3307424
Signed-off-by: Bar Weiner <bweiner@codeaurora.org>
Signed-off-by: Danny Segal <dsegal@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agoUSB: dwc3: Add support for fixing superspeed enumeration issue
Vijayavardhan Vennapusa [Thu, 8 May 2014 08:17:50 +0000 (13:47 +0530)]
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>
[jackp@codeaurora.org: only add u1/u2 disable bits]
Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: add in_lpm flag to struct dwc3
Bar Weiner [Tue, 13 May 2014 12:13:19 +0000 (15:13 +0300)]
usb: dwc3: add in_lpm flag to struct dwc3

This change provides the gadget with awareness regarding
the vendor-specific's low-power-mode status. This is done
in order to enable proper decision making regarding cases
where the gadget would potentially attempt to interface the
hardware when it's in lpm.

Change-Id: I1508fbddd13228fbb7d6d53d91d98a0acaaf3fd7
Signed-off-by: Bar Weiner <bweiner@codeaurora.org>
8 years agousb: dwc3: add support for pwr_event_irq
Bar Weiner [Mon, 19 May 2014 08:18:01 +0000 (11:18 +0300)]
usb: dwc3: add support for pwr_event_irq

Adds support for the pwr_event_irq in general, and for
the L1_OUT pwr event specifically. The support consists of:
1. Enabling the pwr_event_irq based on the DT.
2. Adding a threaded irq handler as well as a centralized function
   (dwc3_pwr_event_handler()) for handling the various power events.
3. Enabling the L1_OUT pwr event. This is done on an
   arch-by-arch basis. The trigger for enabling this is
   dbm_l1_lpm_interrupt().
4. Calling usb_gadget_wakeup() in order to initiate a wakeup sequence
   without sending a remote-wakeup indication to the host.
5. Adding a call from dwc3_msm_resume() to dwc3_pwr_event_handler().
   This is done in order to overcome a situation where
   dwc3_msm_suspend() would have disabled the clocks, thereby
   disabling the ability to read the PWR_STAT register before calling
   the handler function.

Change-Id: Ia548ec2e9ee4a7c6634c87ba24fe4cdbf1221000
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
Signed-off-by: Bar Weiner <bweiner@codeaurora.org>
8 years agousb: dwc3: gadget: ignore suspend interrupt before connect
Dov Levenglick [Sun, 4 May 2014 08:34:45 +0000 (11:34 +0300)]
usb: dwc3: gadget: ignore suspend interrupt before connect

The controller sees a suspend event prior to the the cable connect
or reset events. As a result, it runs through an unnecessary
suspend sequence. Adding a check on the gadget's state avoids
the overhead.
The root cause of this appears to be a situation where the
controller senses/is told that there is a VBUS, but the port
reset is not forthcoming. In such a case, the line state is
interpreted as suspend, and the event is generated.
When VBUS detach is sensed/indicated, the state is returned to
USB_STATE_NOTATTACHED, in preparation for the next cable connect.

Change-Id: I639454ceb0ad3a8ff2c02d527c553a934b8639fc
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
8 years agousb: dwc3: Add missing defines
Jack Pham [Sat, 11 Apr 2015 01:05:53 +0000 (18:05 -0700)]
usb: dwc3: Add missing defines

Add bit definition for the GUSB2PHYCFG ENBLSLPM bit.
Add definition for DWC3_GUCTL_REFCLKPER which is used to set
the reference clock frequency. Also add definition for
DWC3_GDBGLTSSM_LINKSTATE_MASK used to query the HW for
the current LTSSM link state.

Signed-off-by: Jack Pham <jackp@codeaurora.org>
8 years agousb: dwc3: gadget: allow remote-wakeup for SS-USB
Bar Weiner [Thu, 3 Apr 2014 09:47:51 +0000 (12:47 +0300)]
usb: dwc3: gadget: allow remote-wakeup for SS-USB

Remove the restriction in the code that disables the possibility
of device remote wakeup in SS-USB.
Originally, this restriction was coded since suspend/resume in SS-USB
is expected to be performed at the function level, rather than the
device level. However, the suspend is currently done at the device
level, and therefore the corresponding remote wakeup should also
follow in suit.
The concept of function suspend/resume may be revisited in the future.

Change-Id: If071f38c03cf46290536cafad1a13a6818088eb7
Signed-off-by: Bar Weiner <bweiner@codeaurora.org>
8 years agousb: dwc3: Keep track of interrupt statistics
Mayank Rana [Fri, 28 Feb 2014 19:04:38 +0000 (11:04 -0800)]
usb: dwc3: Keep track of interrupt statistics

This change adds debug support to log all received different
events with endpoint0, other endpoints and gadget events. It
tracks these events per endpoint and displays the same.

For each of the endpoint event counters, add the rate (in Hz)
at which it occurs in order to better analyze performance and
aid in optimization.

How to use:
- Mount debugfs
- To see received all dwc3 events/interrupts
cat /sys/kernel/debug/<base_address>.dwc3/int_events
- To clear all received dwc3 events/interrupts
echo 0 > /sys/kernel/debug/<base_address>.dwc3/int_events

Change-Id: Ibf5f3ee57f69c87f94f55a58f50792075be24fbb
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Mayank Rana <mrana@codeaurora.org>