EHCI: HSIC: Fix GPT timer count values used for resume sequence

The counter value to be loaded into GPT timer represents the time
in micro seconds minus 1 for the timer duration.  The current code
incorrectly programs the timer.  Fix it.

Change-Id: Ief8039b4e75910001d31a7c05b3b274e6e66c2da
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
EHCI: HSIC: Handle asynchronous interrupt properly

Runtime PM resume and asynchronous interrupt can run in parallel. When
this happens, there is a possibility of PM usage counter mismatch.
Fix this by checking the return value of pm_runtime_get() and by
disabling the USB interrupt while resuming the HSIC.

Consider asynchronous interrupt case when resuming HSIC during system
resume.

CRs-Fixed: 444883
Change-Id: I315fb6cecffcea83c03037be899e3ff840791c21
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
EHCI: HSIC: Disable asynchronous interrupt when wakeup gpio is present

Controller can generate interrupt asynchronously in low power mode (LPM).
Enable this interrupt in USBCMD register only when wakeup gpio IRQ is
not available.

CRs-Fixed: 444883
Change-Id: I8f68fa63c1c086990ff429cd1224e14a1d34654b
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
usb: host: read bus scaling parameters for HSIC host

Use a bus scaling device tree parameters for the HSIC host node.

Change-Id: I93f57400c6a2a4da2634b50fd67f2d6015eab9c2
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
usb: ehci-msm-hsic: Restore CMD_RUN bit in ehci->command after resume

EHCI driver maintains a copy of USB_CMD contents in ehci->command
variable.  CMD_RUN bit is cleared from this variable to delay SOF
till port is resumed. Restore this bit back in ehci->command after
resume is completed otherwise ehci driver may later use stale
ehci->command value to update USB_CMD register clearing CMD_RUN bit.

Change-Id: I672aa14140f44a8de8757d84fe2305693da18130
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
EHCI: HSIC: fix driver removal function for msm_hsic_host

Upon driver removal function we need to disable the device pm runtime
in order to, first, undo all the logic done in probe and second, to keep
balanced disable depth counter in case of platform driver unbind.

However the removal function can be called also in consequences of
platform_device_del(), in this case the platform device was already
disabled and removed so if we call pm_runtime_disable() again we
decrease the disable_depth for the second time causing for unbalanced
counter.

Therefore we use an if statement to check if the device was already
removed or not.

CRs-Fixed: 445674
Change-Id: I5ff6b20d0f8e811a5c673903ca340f7bcc2e2d78
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: msm_bus: Add device tree support for bus scaling clients

This patch enables clients to specify vectors in device tree
format. Clients will no longer need to specify vectors in
the boards file. Instead, they can add the bus-scaling
related data to their own device-nodes.
The clients can then call an API exposed by the bus driver
which will build the pdata out of those strings.
The registration process using pdata remains unchanged.

Change-Id: I1bba645d031e2cd822f16d8edcdf926a0418618c
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Enable GPU DCVS by default where possible

If a platform has Trustzone support, enable GPU DCVS
automatically without checking the individual soc info
value.

Change-Id: Ie8d965f8d73283a7f3bf55dedc44d550db2408b8
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Add new sysfs node to list GPU clock frequencies

Add a new sysfs node to communicate available GPU clock frequencies
to userspace for the power daemons.

Change-Id: I2479217aa797e2066cc50476ef7f73c5cae8aebe
Signed-off-by: Anshuman Dani <adani@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Set sysfs max clock for devices with no power scale policy

When the sysfs entry for max clock is updated, set it immediately for the
devices that has no power scale policy. This prevents the device from
running with undesired clock.

Change-Id: I3211234f6d2afe4c2de115dace70b332d2b30f21
CRs-fixed: 408963
Signed-off-by: Ranjhith Kalisamy <ranjhith@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Add max and min power level controls in sysfs

Add min_pwrlevel, max_pwrlevel and thermal_pwrlevel to give a
privileged user more control over which power levels are considered
during DCVS power management.  max_pwrlevel is the maximum power
level that the system can go to at any time, min_pwrlevel represents
the lowest power level.  DCVS will chose any level between these
two extremes.  thermal_pwrlevel allows a daemon to set an absolute
top for frequency to prevent thermal issues. The effective maximum
power level is considered to be the lower of thermal or max.

Also added is num_pwrlevels that shows the number of active power
levels. This corresponds to the gpu frequencies in
available_gpu_frequencies.

Change-Id: Ic0dedbad20102d9a3c3350055e6fcd10358fc53d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Process all idle checks

Rather than ignore some categories of idle events,
bin the events with small timelines and process all
events with the GPU DCVS algorithm.

CRs-Fixed: 427559
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Change-Id: I1a5e8d8af6020a08cf95a9daa934e825bc5f2854
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Bump up the GPU frequency for long batch processing

Compute workloads run without kernel interaction for long periods
of time.  If one is identified early, increase the frequency to
finish it as fast as possible, rather than waiting for the standard
algorithm to do so.

Change-Id: I213ccabfae5e1000cdc34bc1d92bdc3bad86383d
CRs-Fixed: 441847
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Remove extra interrupts when setting MMU state

The interrupts added to the ringbuffer on PTFLUSH and TLBUPDATE
were causing a major increase in the number of interrupts from the GPU.
This was leading to increase in power and loss of performance. Add a check
to turn off IOMMU clocks when going to SLEEP.

Change-Id: I41617dd3b7b3f7d9622523f2a1407b912dbd989e
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
auto_hotplug.c: use a dedicated workqueue instead of queueing to the global kernel queue list for testing purposes.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>