drm/ttm: expose CPU address of DMA-allocated pages

Pages allocated using the DMA API have a coherent memory mapping. Make
this mapping visible to drivers so they can decide to use it instead of
creating their own redundant one.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: David Airlie <airlied@linux.ie>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau/pwr: tidy

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/gk104/pwr: implement PGOB disable method

As documented at:

ftp://download.nvidia.com/open-gpu-doc/gk104-disable-graphics-power-gating/1/gk104-disable-graphics-power-gating.txt

NVIDIA were not able document the steps necessary to detect whether this
is required or not at this time.  However, they did confirm that this
procedure is safe to perform unconditionally on GK104/6.  GK107 does not
have the power gating feature, and it was recommended that we do not
perform these steps there as the effects were not verified.

The disable path is from observing the binary driver, and not
documented in the link above.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/gk104/gr: disable PGOB at init time

This removes the previous hack that worked on some boards.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/gk110b/gr: initvals differ from gk110

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/gk208-/gr: stop touching 0x260 inappropriately

As a side note.. It's a bit hard to figure out how to name this commit..
GK20A is NVEA, which is before NV108 (GK208).. Confusing.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau/device: register for acpi events

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau/clk: schedule pstate changes through a workqueue

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau/clk: allow selection of different power state for ac vs battery

v2:
- s/init/fini/ typo, reported by Alex

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau: expose pstate selection per-power source in sysfs

echo ac:id >> pstate # select mode when on mains power
echo dc:id >> pstate # select mode when on battery
echo id >> pstate # select mode for both

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau/kms: take more care when pulling down accelerated fbcon

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau/kms: restore acceleration before fb_set_suspend() resumes

This *should* be safe these days.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau: support for probing platform devices

Add a platform driver for Nouveau devices declared using the device tree
or platform data. This driver currently supports GK20A on Tegra
platforms and is only compiled for these platforms if Nouveau is
enabled.

Nouveau will probe the chip type itself using the BOOT0 register, so all
this driver really needs to do is to make sure the module is powered and
its clocks active before calling nouveau_drm_platform_probe().

Heavily based on work done by Thierry Reding.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau/bar: add noncached ioremap property

Some BARs (like GK20A's) do not support being ioremapped write-combined.
Add a boolean property to the BAR structure and handle that case in the
Nouveau BO implementation.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
drm/gk20a: add BAR instance

GK20A's BAR is functionally identical to NVC0's, but do not support
being ioremapped write-combined. Create a BAR instance for GK20A that
reflect that state.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
drm/nve4/graph: do not crash if no power device present

Detect and workaround the absence of a power device so chips that do not
feature one (e.g. GK20A) can still use this driver.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau/pwr/macros: Stop playing Russian roulette on data memory

Signed-off-by: Roy Spliet <rspliet@eclipso.eu>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau: map pages using DMA API

The DMA API is the recommended way to map pages no matter what the
underlying bus is. Use the DMA functions for page mapping and remove
currently existing wrappers.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau/perfmon: do not forget to destroy the engine context

This fixes a crash when we reload Nouveau DRM.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drm/nouveau/clk: make therm and volt devices optional

Allow the clock subsystem to operate even if voltage and thermal devices
are not set for the device (for people with watercooling! ;))

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>