msm: kgsl: Rename and expand calc_idle

Rather then just calculating the idle time and returning it,
there is value in returning the raw statistics and let the caller
use them as they see fit.  Rename calc_idle to power_stats, and
use a structure to pass back the total_time and busy_time.  The
structure allows for future expansion as well as providing enough
information for others to perform interesting power and load related
calculations.

Change-Id: I5132060fd6c4c6867b39a15fccb2380108394225
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Cleanup sysfs device file creation

Take the generic sysfs create/remove functions from kgsl_sharedmem.c
and share their creamy goodness with the rest of the driver.

Change-Id: Ia5ba94d23ed551289fcb6fbb196c1749e6c43b65
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Fix gpuaddr to vaddr conversion

The virtual address for a given gpu address was being calculated
incorrectly, instead of adding the offset to the base virtual
address the offset was being subtracted.

Change-Id: I769d7e9d2cfd0dfe03a8c6cc19558e5455fa9b49
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Fixup external memory offsets

Offsets passed in for external memory chunks are not always
4K aligned, so make sure the differences are accounted for.

CRs-fixed: 290267
Change-Id: I3c11b7f853679e00af8ebc9c7f54443d2fe6ec6d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Fix mmu pagefaults after recovery

Add the context switch identifier code before
changing pagetables

Change-Id: I4a418c810eea8b788b9d7cde2f7020424d177887
CRs-fixed: 285814
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Fix access to ringbuffer in recovery code

Whenever the read pointer is used to access the
ringbuffer in recovery code looping has been introduced
in places where it was missing

Change-Id: I7d122f553ac999c73dc5c1c0b2fbbf17e354b18f
CRs-fixed: 285120
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: remove implementation of IOCTL_KGSL_DEVICE_REGREAD

This ioctl isn't used by userspace.

Change-Id: If51a949edc6882a92aa925d5c3b2ec961462f7e8
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Reconstruct the ringbuffer correctly during recovery

Make sure while extracting commands the identifier
commands do not get added twice.

Change-Id: Ic1593ef091489c5bcbdbc3e06fe815f521752600
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: make device specific ioctl function optional

At least some of the device specific ioctls are no longer
needed.

Change-Id: I352942e5202a04db093bee9a8016ae1fb8d492e8
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: remove implementation of IOCTL_KGSL_CMDWINDOW_WRITE

This ioctl isn't used by userspace. Since most of z180_cmdwindow_write()
existed to support this ioctl, it can now be simplified a bit.

Change-Id: I562ab9dc6d8012395ecec4bff327f6f2f182be95
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: reset more registers during gmem save/restore

The gmem save and restore code needs additional registers to
be known states to avoid visual artifacts.

CRs-fixed: 291124
Change-Id: I1312ac1c20610943dc7ab97e55adaf1566ddf5f5
Signed-off-by: Wei Zou <wzou@codeaurora.org>
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Add pwrscale policy infrastructure

Add a new infrastructure to allow for pluggable
GPU power scaling policies.

Change-Id: Ic0dedbade19812f6fd92023bf7d25f6a9046d0c9
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Trustzone power scaling policy

Add a pwrscale policy for the trustzone based
frequency scaling alogrithm.

Change-Id: Ic0dedbadcb8a0e83baca74fab9f7d1ae0ffaf935
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Add PM_QOS requirements for KGSL

Change-Id: Iaaae1dac8809695270125757d6ac41817b7aca28
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
msm: kgsl: Remove <mach/msm_bus.h> from msm_kgsl.h

msm_kgsl.h doesn't need msm_bus.h included inside of it,
and since it is the public facing header, it is preferable
to keep it as clean as possible.  Remove it, and fix up the
missing dependencies in a few of the driver files.

Change-Id: Ic0dedbad56ad36d81beaae4ed3dfc0f46581c46c
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Save power when the display is off.

Use the early_suspend functionality to monitor display state.
If the display is off the GPU does not need to be in turbo mode.
Wait until late resume to enter turbo mode, and if the core is
idle, turn off the GPU clocks.

Change-Id: I961fc45b2bbae80bf0e3fc8f59377e6104e9c4a6
CRs-fixed: 290139
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
msm: kgsl: Load firmware for A225 GPU

Change-Id: Ic0dedbadeb7c8726d1c9697b6eb1143cb3a59571
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Track the parent device for the driver

Rather then store the platform_device pointer,
remember the generic parent device which gets used in
more places and makes the core code just slightly less
dependent on platform devices in general.

Change-Id: Ic0dedbade7b21732ff61c998dc1de68aa1f372af
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Add a sysfs entry to set the maximum allowable clock speed

Add a new sysfs entry 'max_gpuclk' to set the maximum allowable
clock speed under any circumstances.  This mainly used for thermal
mitigation.

Change-Id: I0406f8a9fa847e05de4ac665913ba11fd237e05a
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
msm: kgsl: put gpu_id into struct kgsl_devinfo

The field gmem_hostbaseaddr has never been used by userspace
and has always been set to 0. It is being replaced with the
gpu_id field which will contain the revision of the GPU,
for example 200 for adreno200.

Change-Id: I48347da5d430a3aa1db588b4fe54febe7eb44476
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>