Commit 90c37067 authored by Dave Airlie's avatar Dave Airlie

Merge tag 'drm/for-3.13-rc1' of git://anongit.freedesktop.org/tegra/linux into drm-next

drm/tegra: Changes for v3.13-rc1

The biggest part of the changes is the decoupling of the host1x and DRM
drivers followed by the move of Tegra DRM back to drivers/gpu/drm/tegra
from whence it came. There is a lot of cleanup as well, and the drivers
can now be properly unloaded and reloaded.

HDMI support for the Tegra114 SoC was contributed by Mikko Perttunen.

gr2d support was extended to Tegra114 and the gr3d driver that has been
in the works for quite some time finally made it in. All pieces to run
an OpenGL driver on top of an upstream kernel are now available.

Support for syncpoint bases was added by Arto Merilainen. This is useful
for synchronizing between command streams from different engines such as
gr2d and gr3d.

Erik Faye-Lund and Wei Yongjun contributed various small fixes. Thanks!

* tag 'drm/for-3.13-rc1' of git://anongit.freedesktop.org/tegra/linux: (45 commits)
  drm/tegra: Reserve syncpoint base for gr3d
  drm/tegra: Reserve base for gr2d
  drm/tegra: Deliver syncpoint base to user space
  gpu: host1x: Add syncpoint base support
  gpu: host1x: Add 'flags' field to syncpt request
  drm/tegra: Disable clock on probe failure
  gpu: host1x: Disable clock on probe failure
  drm/tegra: Support bottom-up buffer objects
  drm/tegra: Add support for tiled buffer objects
  drm/tegra: Add 3D support
  drm/tegra: Introduce tegra_drm_submit()
  drm/tegra: Use symbolic names for gr2d registers
  drm/tegra: Start connectors with correct DPMS mode
  drm/tegra: hdmi: Enable VDD earlier for hotplug/DDC
  drm/tegra: hdmi: Fix build warnings
  drm/tegra: hdmi: Detect DVI-only displays
  drm/tegra: Add Tegra114 HDMI support
  drm/tegra: hdmi: Parameterize based on compatible property
  drm/tegra: hdmi: Rename tegra{2,3} to tegra{20,30}
  gpu: host1x: Add support for Tegra114
  ...
parents cc87509d 977386a0
...@@ -2816,7 +2816,9 @@ L: dri-devel@lists.freedesktop.org ...@@ -2816,7 +2816,9 @@ L: dri-devel@lists.freedesktop.org
L: linux-tegra@vger.kernel.org L: linux-tegra@vger.kernel.org
T: git git://anongit.freedesktop.org/tegra/linux.git T: git git://anongit.freedesktop.org/tegra/linux.git
S: Maintained S: Maintained
F: drivers/gpu/drm/tegra/
F: drivers/gpu/host1x/ F: drivers/gpu/host1x/
F: include/linux/host1x.h
F: include/uapi/drm/tegra_drm.h F: include/uapi/drm/tegra_drm.h
F: Documentation/devicetree/bindings/gpu/nvidia,tegra20-host1x.txt F: Documentation/devicetree/bindings/gpu/nvidia,tegra20-host1x.txt
......
...@@ -189,3 +189,5 @@ source "drivers/gpu/drm/tilcdc/Kconfig" ...@@ -189,3 +189,5 @@ source "drivers/gpu/drm/tilcdc/Kconfig"
source "drivers/gpu/drm/qxl/Kconfig" source "drivers/gpu/drm/qxl/Kconfig"
source "drivers/gpu/drm/msm/Kconfig" source "drivers/gpu/drm/msm/Kconfig"
source "drivers/gpu/drm/tegra/Kconfig"
...@@ -57,4 +57,5 @@ obj-$(CONFIG_DRM_OMAP) += omapdrm/ ...@@ -57,4 +57,5 @@ obj-$(CONFIG_DRM_OMAP) += omapdrm/
obj-$(CONFIG_DRM_TILCDC) += tilcdc/ obj-$(CONFIG_DRM_TILCDC) += tilcdc/
obj-$(CONFIG_DRM_QXL) += qxl/ obj-$(CONFIG_DRM_QXL) += qxl/
obj-$(CONFIG_DRM_MSM) += msm/ obj-$(CONFIG_DRM_MSM) += msm/
obj-$(CONFIG_DRM_TEGRA) += tegra/
obj-y += i2c/ obj-y += i2c/
...@@ -567,6 +567,14 @@ drm_crtc_helper_disable(struct drm_crtc *crtc) ...@@ -567,6 +567,14 @@ drm_crtc_helper_disable(struct drm_crtc *crtc)
continue; continue;
connector->encoder = NULL; connector->encoder = NULL;
/*
* drm_helper_disable_unused_functions() ought to be
* doing this, but since we've decoupled the encoder
* from the connector above, the required connection
* between them is henceforth no longer available.
*/
connector->dpms = DRM_MODE_DPMS_OFF;
} }
} }
......
...@@ -396,7 +396,7 @@ long drm_ioctl(struct file *filp, ...@@ -396,7 +396,7 @@ long drm_ioctl(struct file *filp,
err_i1: err_i1:
if (!ioctl) if (!ioctl)
DRM_DEBUG("invalid iotcl: pid=%d, dev=0x%lx, auth=%d, cmd=0x%02x, nr=0x%02x\n", DRM_DEBUG("invalid ioctl: pid=%d, dev=0x%lx, auth=%d, cmd=0x%02x, nr=0x%02x\n",
task_pid_nr(current), task_pid_nr(current),
(long)old_encode_dev(file_priv->minor->device), (long)old_encode_dev(file_priv->minor->device),
file_priv->authenticated, cmd, nr); file_priv->authenticated, cmd, nr);
......
config DRM_TEGRA config DRM_TEGRA
bool "NVIDIA Tegra DRM" bool "NVIDIA Tegra DRM"
depends on ARCH_TEGRA || ARCH_MULTIPLATFORM
depends on DRM depends on DRM
select TEGRA_HOST1X
select DRM_KMS_HELPER select DRM_KMS_HELPER
select DRM_KMS_FB_HELPER select DRM_KMS_FB_HELPER
select FB_SYS_FILLRECT select FB_SYS_FILLRECT
...@@ -14,6 +16,11 @@ config DRM_TEGRA ...@@ -14,6 +16,11 @@ config DRM_TEGRA
if DRM_TEGRA if DRM_TEGRA
config DRM_TEGRA_DEBUG
bool "NVIDIA Tegra DRM debug support"
help
Say yes here to enable debugging support.
config DRM_TEGRA_STAGING config DRM_TEGRA_STAGING
bool "Enable HOST1X interface" bool "Enable HOST1X interface"
depends on STAGING depends on STAGING
...@@ -22,9 +29,4 @@ config DRM_TEGRA_STAGING ...@@ -22,9 +29,4 @@ config DRM_TEGRA_STAGING
If unsure, choose N. If unsure, choose N.
config DRM_TEGRA_DEBUG
bool "NVIDIA Tegra DRM debug support"
help
Say yes here to enable debugging support.
endif endif
ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG
tegra-drm-y := \
bus.o \
drm.o \
gem.o \
fb.o \
dc.o \
output.o \
rgb.o \
hdmi.o \
gr2d.o \
gr3d.o
obj-$(CONFIG_DRM_TEGRA) += tegra-drm.o
/*
* Copyright (C) 2013 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include "drm.h"
static int drm_host1x_set_busid(struct drm_device *dev,
struct drm_master *master)
{
const char *device = dev_name(dev->dev);
const char *driver = dev->driver->name;
const char *bus = dev->dev->bus->name;
int length;
master->unique_len = strlen(bus) + 1 + strlen(device);
master->unique_size = master->unique_len;
master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
if (!master->unique)
return -ENOMEM;
snprintf(master->unique, master->unique_len + 1, "%s:%s", bus, device);
length = strlen(driver) + 1 + master->unique_len;
dev->devname = kmalloc(length + 1, GFP_KERNEL);
if (!dev->devname)
return -ENOMEM;
snprintf(dev->devname, length + 1, "%s@%s", driver, master->unique);
return 0;
}
static struct drm_bus drm_host1x_bus = {
.bus_type = DRIVER_BUS_HOST1X,
.set_busid = drm_host1x_set_busid,
};
int drm_host1x_init(struct drm_driver *driver, struct host1x_device *device)
{
struct drm_device *drm;
int ret;
INIT_LIST_HEAD(&driver->device_list);
driver->bus = &drm_host1x_bus;
drm = drm_dev_alloc(driver, &device->dev);
if (!drm)
return -ENOMEM;
ret = drm_dev_register(drm, 0);
if (ret)
goto err_free;
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", driver->name,
driver->major, driver->minor, driver->patchlevel,
driver->date, drm->primary->index);
return 0;
err_free:
drm_dev_free(drm);
return ret;
}
void drm_host1x_exit(struct drm_driver *driver, struct host1x_device *device)
{
struct tegra_drm *tegra = dev_get_drvdata(&device->dev);
drm_put_dev(tegra->drm);
}
...@@ -8,13 +8,9 @@ ...@@ -8,13 +8,9 @@
*/ */
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/debugfs.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/clk/tegra.h> #include <linux/clk/tegra.h>
#include <linux/debugfs.h>
#include "host1x_client.h"
#include "dc.h" #include "dc.h"
#include "drm.h" #include "drm.h"
#include "gem.h" #include "gem.h"
...@@ -51,6 +47,8 @@ static int tegra_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -51,6 +47,8 @@ static int tegra_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
window.dst.h = crtc_h; window.dst.h = crtc_h;
window.format = tegra_dc_format(fb->pixel_format); window.format = tegra_dc_format(fb->pixel_format);
window.bits_per_pixel = fb->bits_per_pixel; window.bits_per_pixel = fb->bits_per_pixel;
window.bottom_up = tegra_fb_is_bottom_up(fb);
window.tiled = tegra_fb_is_tiled(fb);
for (i = 0; i < drm_format_num_planes(fb->pixel_format); i++) { for (i = 0; i < drm_format_num_planes(fb->pixel_format); i++) {
struct tegra_bo *bo = tegra_fb_get_plane(fb, i); struct tegra_bo *bo = tegra_fb_get_plane(fb, i);
...@@ -97,8 +95,11 @@ static int tegra_plane_disable(struct drm_plane *plane) ...@@ -97,8 +95,11 @@ static int tegra_plane_disable(struct drm_plane *plane)
static void tegra_plane_destroy(struct drm_plane *plane) static void tegra_plane_destroy(struct drm_plane *plane)
{ {
struct tegra_plane *p = to_tegra_plane(plane);
tegra_plane_disable(plane); tegra_plane_disable(plane);
drm_plane_cleanup(plane); drm_plane_cleanup(plane);
kfree(p);
} }
static const struct drm_plane_funcs tegra_plane_funcs = { static const struct drm_plane_funcs tegra_plane_funcs = {
...@@ -124,7 +125,7 @@ static int tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc) ...@@ -124,7 +125,7 @@ static int tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc)
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
struct tegra_plane *plane; struct tegra_plane *plane;
plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL); plane = kzalloc(sizeof(*plane), GFP_KERNEL);
if (!plane) if (!plane)
return -ENOMEM; return -ENOMEM;
...@@ -133,8 +134,10 @@ static int tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc) ...@@ -133,8 +134,10 @@ static int tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc)
err = drm_plane_init(drm, &plane->base, 1 << dc->pipe, err = drm_plane_init(drm, &plane->base, 1 << dc->pipe,
&tegra_plane_funcs, plane_formats, &tegra_plane_funcs, plane_formats,
ARRAY_SIZE(plane_formats), false); ARRAY_SIZE(plane_formats), false);
if (err < 0) if (err < 0) {
kfree(plane);
return err; return err;
}
} }
return 0; return 0;
...@@ -145,6 +148,7 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y, ...@@ -145,6 +148,7 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
{ {
unsigned int format = tegra_dc_format(fb->pixel_format); unsigned int format = tegra_dc_format(fb->pixel_format);
struct tegra_bo *bo = tegra_fb_get_plane(fb, 0); struct tegra_bo *bo = tegra_fb_get_plane(fb, 0);
unsigned int h_offset = 0, v_offset = 0;
unsigned long value; unsigned long value;
tegra_dc_writel(dc, WINDOW_A_SELECT, DC_CMD_DISPLAY_WINDOW_HEADER); tegra_dc_writel(dc, WINDOW_A_SELECT, DC_CMD_DISPLAY_WINDOW_HEADER);
...@@ -156,6 +160,32 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y, ...@@ -156,6 +160,32 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
tegra_dc_writel(dc, fb->pitches[0], DC_WIN_LINE_STRIDE); tegra_dc_writel(dc, fb->pitches[0], DC_WIN_LINE_STRIDE);
tegra_dc_writel(dc, format, DC_WIN_COLOR_DEPTH); tegra_dc_writel(dc, format, DC_WIN_COLOR_DEPTH);
if (tegra_fb_is_tiled(fb)) {
value = DC_WIN_BUFFER_ADDR_MODE_TILE_UV |
DC_WIN_BUFFER_ADDR_MODE_TILE;
} else {
value = DC_WIN_BUFFER_ADDR_MODE_LINEAR_UV |
DC_WIN_BUFFER_ADDR_MODE_LINEAR;
}
tegra_dc_writel(dc, value, DC_WIN_BUFFER_ADDR_MODE);
/* make sure bottom-up buffers are properly displayed */
if (tegra_fb_is_bottom_up(fb)) {
value = tegra_dc_readl(dc, DC_WIN_WIN_OPTIONS);
value |= INVERT_V;
tegra_dc_writel(dc, value, DC_WIN_WIN_OPTIONS);
v_offset += fb->height - 1;
} else {
value = tegra_dc_readl(dc, DC_WIN_WIN_OPTIONS);
value &= ~INVERT_V;
tegra_dc_writel(dc, value, DC_WIN_WIN_OPTIONS);
}
tegra_dc_writel(dc, h_offset, DC_WINBUF_ADDR_H_OFFSET);
tegra_dc_writel(dc, v_offset, DC_WINBUF_ADDR_V_OFFSET);
value = GENERAL_UPDATE | WIN_A_UPDATE; value = GENERAL_UPDATE | WIN_A_UPDATE;
tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL); tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL);
...@@ -255,14 +285,26 @@ static int tegra_dc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, ...@@ -255,14 +285,26 @@ static int tegra_dc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
return 0; return 0;
} }
static void drm_crtc_clear(struct drm_crtc *crtc)
{
memset(crtc, 0, sizeof(*crtc));
}
static void tegra_dc_destroy(struct drm_crtc *crtc)
{
drm_crtc_cleanup(crtc);
drm_crtc_clear(crtc);
}
static const struct drm_crtc_funcs tegra_crtc_funcs = { static const struct drm_crtc_funcs tegra_crtc_funcs = {
.page_flip = tegra_dc_page_flip, .page_flip = tegra_dc_page_flip,
.set_config = drm_crtc_helper_set_config, .set_config = drm_crtc_helper_set_config,
.destroy = drm_crtc_cleanup, .destroy = tegra_dc_destroy,
}; };
static void tegra_crtc_disable(struct drm_crtc *crtc) static void tegra_crtc_disable(struct drm_crtc *crtc)
{ {
struct tegra_dc *dc = to_tegra_dc(crtc);
struct drm_device *drm = crtc->dev; struct drm_device *drm = crtc->dev;
struct drm_plane *plane; struct drm_plane *plane;
...@@ -277,6 +319,8 @@ static void tegra_crtc_disable(struct drm_crtc *crtc) ...@@ -277,6 +319,8 @@ static void tegra_crtc_disable(struct drm_crtc *crtc)
} }
} }
} }
drm_vblank_off(drm, dc->pipe);
} }
static bool tegra_crtc_mode_fixup(struct drm_crtc *crtc, static bool tegra_crtc_mode_fixup(struct drm_crtc *crtc,
...@@ -491,9 +535,22 @@ int tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index, ...@@ -491,9 +535,22 @@ int tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index,
tegra_dc_writel(dc, window->stride[0], DC_WIN_LINE_STRIDE); tegra_dc_writel(dc, window->stride[0], DC_WIN_LINE_STRIDE);
} }
if (window->bottom_up)
v_offset += window->src.h - 1;
tegra_dc_writel(dc, h_offset, DC_WINBUF_ADDR_H_OFFSET); tegra_dc_writel(dc, h_offset, DC_WINBUF_ADDR_H_OFFSET);
tegra_dc_writel(dc, v_offset, DC_WINBUF_ADDR_V_OFFSET); tegra_dc_writel(dc, v_offset, DC_WINBUF_ADDR_V_OFFSET);
if (window->tiled) {
value = DC_WIN_BUFFER_ADDR_MODE_TILE_UV |
DC_WIN_BUFFER_ADDR_MODE_TILE;
} else {
value = DC_WIN_BUFFER_ADDR_MODE_LINEAR_UV |
DC_WIN_BUFFER_ADDR_MODE_LINEAR;
}
tegra_dc_writel(dc, value, DC_WIN_BUFFER_ADDR_MODE);
value = WIN_ENABLE; value = WIN_ENABLE;
if (yuv) { if (yuv) {
...@@ -512,6 +569,9 @@ int tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index, ...@@ -512,6 +569,9 @@ int tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index,
value |= COLOR_EXPAND; value |= COLOR_EXPAND;
} }
if (window->bottom_up)
value |= INVERT_V;
tegra_dc_writel(dc, value, DC_WIN_WIN_OPTIONS); tegra_dc_writel(dc, value, DC_WIN_WIN_OPTIONS);
/* /*
...@@ -1041,30 +1101,30 @@ static int tegra_dc_debugfs_exit(struct tegra_dc *dc) ...@@ -1041,30 +1101,30 @@ static int tegra_dc_debugfs_exit(struct tegra_dc *dc)
return 0; return 0;
} }
static int tegra_dc_drm_init(struct host1x_client *client, static int tegra_dc_init(struct host1x_client *client)
struct drm_device *drm)
{ {
struct tegra_drm *tegra = dev_get_drvdata(client->parent);
struct tegra_dc *dc = host1x_client_to_dc(client); struct tegra_dc *dc = host1x_client_to_dc(client);
int err; int err;
dc->pipe = drm->mode_config.num_crtc; dc->pipe = tegra->drm->mode_config.num_crtc;
drm_crtc_init(drm, &dc->base, &tegra_crtc_funcs); drm_crtc_init(tegra->drm, &dc->base, &tegra_crtc_funcs);
drm_mode_crtc_set_gamma_size(&dc->base, 256); drm_mode_crtc_set_gamma_size(&dc->base, 256);
drm_crtc_helper_add(&dc->base, &tegra_crtc_helper_funcs); drm_crtc_helper_add(&dc->base, &tegra_crtc_helper_funcs);
err = tegra_dc_rgb_init(drm, dc); err = tegra_dc_rgb_init(tegra->drm, dc);
if (err < 0 && err != -ENODEV) { if (err < 0 && err != -ENODEV) {
dev_err(dc->dev, "failed to initialize RGB output: %d\n", err); dev_err(dc->dev, "failed to initialize RGB output: %d\n", err);
return err; return err;
} }
err = tegra_dc_add_planes(drm, dc); err = tegra_dc_add_planes(tegra->drm, dc);
if (err < 0) if (err < 0)
return err; return err;
if (IS_ENABLED(CONFIG_DEBUG_FS)) { if (IS_ENABLED(CONFIG_DEBUG_FS)) {
err = tegra_dc_debugfs_init(dc, drm->primary); err = tegra_dc_debugfs_init(dc, tegra->drm->primary);
if (err < 0) if (err < 0)
dev_err(dc->dev, "debugfs setup failed: %d\n", err); dev_err(dc->dev, "debugfs setup failed: %d\n", err);
} }
...@@ -1080,7 +1140,7 @@ static int tegra_dc_drm_init(struct host1x_client *client, ...@@ -1080,7 +1140,7 @@ static int tegra_dc_drm_init(struct host1x_client *client,
return 0; return 0;
} }
static int tegra_dc_drm_exit(struct host1x_client *client) static int tegra_dc_exit(struct host1x_client *client)
{ {
struct tegra_dc *dc = host1x_client_to_dc(client); struct tegra_dc *dc = host1x_client_to_dc(client);
int err; int err;
...@@ -1103,13 +1163,12 @@ static int tegra_dc_drm_exit(struct host1x_client *client) ...@@ -1103,13 +1163,12 @@ static int tegra_dc_drm_exit(struct host1x_client *client)
} }
static const struct host1x_client_ops dc_client_ops = { static const struct host1x_client_ops dc_client_ops = {
.drm_init = tegra_dc_drm_init, .init = tegra_dc_init,
.drm_exit = tegra_dc_drm_exit, .exit = tegra_dc_exit,
}; };
static int tegra_dc_probe(struct platform_device *pdev) static int tegra_dc_probe(struct platform_device *pdev)
{ {
struct host1x_drm *host1x = host1x_get_drm_data(pdev->dev.parent);
struct resource *regs; struct resource *regs;
struct tegra_dc *dc; struct tegra_dc *dc;
int err; int err;
...@@ -1153,7 +1212,7 @@ static int tegra_dc_probe(struct platform_device *pdev) ...@@ -1153,7 +1212,7 @@ static int tegra_dc_probe(struct platform_device *pdev)
return err; return err;
} }
err = host1x_register_client(host1x, &dc->client); err = host1x_client_register(&dc->client);
if (err < 0) { if (err < 0) {
dev_err(&pdev->dev, "failed to register host1x client: %d\n", dev_err(&pdev->dev, "failed to register host1x client: %d\n",
err); err);
...@@ -1167,17 +1226,22 @@ static int tegra_dc_probe(struct platform_device *pdev) ...@@ -1167,17 +1226,22 @@ static int tegra_dc_probe(struct platform_device *pdev)
static int tegra_dc_remove(struct platform_device *pdev) static int tegra_dc_remove(struct platform_device *pdev)
{ {
struct host1x_drm *host1x = host1x_get_drm_data(pdev->dev.parent);
struct tegra_dc *dc = platform_get_drvdata(pdev); struct tegra_dc *dc = platform_get_drvdata(pdev);
int err; int err;
err = host1x_unregister_client(host1x, &dc->client); err = host1x_client_unregister(&dc->client);
if (err < 0) { if (err < 0) {
dev_err(&pdev->dev, "failed to unregister host1x client: %d\n", dev_err(&pdev->dev, "failed to unregister host1x client: %d\n",
err); err);
return err; return err;
} }
err = tegra_dc_rgb_remove(dc);
if (err < 0) {
dev_err(&pdev->dev, "failed to remove RGB output: %d\n", err);
return err;
}
clk_disable_unprepare(dc->clk); clk_disable_unprepare(dc->clk);
return 0; return 0;
......
...@@ -302,6 +302,7 @@ ...@@ -302,6 +302,7 @@
#define DC_WIN_CSC_KVB 0x618 #define DC_WIN_CSC_KVB 0x618
#define DC_WIN_WIN_OPTIONS 0x700 #define DC_WIN_WIN_OPTIONS 0x700
#define INVERT_V (1 << 2)
#define COLOR_EXPAND (1 << 6) #define COLOR_EXPAND (1 << 6)
#define CSC_ENABLE (1 << 18) #define CSC_ENABLE (1 << 18)
#define WIN_ENABLE (1 << 30) #define WIN_ENABLE (1 << 30)
...@@ -365,6 +366,10 @@ ...@@ -365,6 +366,10 @@
#define DC_WIN_BUF_STRIDE 0x70b #define DC_WIN_BUF_STRIDE 0x70b
#define DC_WIN_UV_BUF_STRIDE 0x70c #define DC_WIN_UV_BUF_STRIDE 0x70c
#define DC_WIN_BUFFER_ADDR_MODE 0x70d #define DC_WIN_BUFFER_ADDR_MODE 0x70d
#define DC_WIN_BUFFER_ADDR_MODE_LINEAR (0 << 0)
#define DC_WIN_BUFFER_ADDR_MODE_TILE (1 << 0)
#define DC_WIN_BUFFER_ADDR_MODE_LINEAR_UV (0 << 16)
#define DC_WIN_BUFFER_ADDR_MODE_TILE_UV (1 << 16)
#define DC_WIN_DV_CONTROL 0x70e #define DC_WIN_DV_CONTROL 0x70e
#define DC_WIN_BLEND_NOKEY 0x70f #define DC_WIN_BLEND_NOKEY 0x70f
......
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
#ifndef HOST1X_DRM_H #ifndef HOST1X_DRM_H
#define HOST1X_DRM_H 1 #define HOST1X_DRM_H 1
#include <uapi/drm/tegra_drm.h>
#include <linux/host1x.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_edid.h> #include <drm/drm_edid.h>
#include <drm/drm_fb_helper.h> #include <drm/drm_fb_helper.h>
#include <drm/drm_fixed.h> #include <drm/drm_fixed.h>
#include <uapi/drm/tegra_drm.h>
#include "host1x.h"
struct tegra_fb { struct tegra_fb {
struct drm_framebuffer base; struct drm_framebuffer base;
...@@ -30,17 +30,8 @@ struct tegra_fbdev { ...@@ -30,17 +30,8 @@ struct tegra_fbdev {
struct tegra_fb *fb; struct tegra_fb *fb;
}; };
struct host1x_drm { struct tegra_drm {
struct drm_device *drm; struct drm_device *drm;
struct device *dev;
void __iomem *regs;
struct clk *clk;
int syncpt;
int irq;
struct mutex drm_clients_lock;
struct list_head drm_clients;
struct list_head drm_active;
struct mutex clients_lock; struct mutex clients_lock;
struct list_head clients; struct list_head clients;
...@@ -48,66 +39,60 @@ struct host1x_drm { ...@@ -48,66 +39,60 @@ struct host1x_drm {
struct tegra_fbdev *fbdev; struct tegra_fbdev *fbdev;
}; };
struct host1x_client; struct tegra_drm_client;
struct host1x_drm_context { struct tegra_drm_context {
struct host1x_client *client; struct tegra_drm_client *client;
struct host1x_channel *channel; struct host1x_channel *channel;
struct list_head list; struct list_head list;
}; };
struct host1x_client_ops { struct tegra_drm_client_ops {
int (*drm_init)(struct host1x_client *client, struct drm_device *drm); int (*open_channel)(struct tegra_drm_client *client,
int (*drm_exit)(struct host1x_client *client); struct tegra_drm_context *context);
int (*open_channel)(struct host1x_client *client, void (*close_channel)(struct tegra_drm_context *context);
struct host1x_drm_context *context); int (*is_addr_reg)(struct device *dev, u32 class, u32 offset);
void (*close_channel)(struct host1x_drm_context *context); int (*submit)(struct tegra_drm_context *context,
int (*submit)(struct host1x_drm_context *context,
struct drm_tegra_submit *args, struct drm_device *drm, struct drm_tegra_submit *args, struct drm_device *drm,
struct drm_file *file); struct drm_file *file);
}; };
struct host1x_drm_file { int tegra_drm_submit(struct tegra_drm_context *context,
struct list_head contexts; struct drm_tegra_submit *args, struct drm_device *drm,
}; struct drm_file *file);
struct host1x_client {
struct host1x_drm *host1x;
struct device *dev;
const struct host1x_client_ops *ops;
enum host1x_class class;
struct host1x_channel *channel;
struct host1x_syncpt **syncpts;
unsigned int num_syncpts;
struct tegra_drm_client {
struct host1x_client base;
struct list_head list; struct list_head list;
const struct tegra_drm_client_ops *ops;
}; };
extern int host1x_drm_init(struct host1x_drm *host1x, struct drm_device *drm); static inline struct tegra_drm_client *
extern int host1x_drm_exit(struct host1x_drm *host1x); host1x_to_drm_client(struct host1x_client *client)
{
return container_of(client, struct tegra_drm_client, base);
}
extern int tegra_drm_register_client(struct tegra_drm *tegra,
struct tegra_drm_client *client);
extern int tegra_drm_unregister_client(struct tegra_drm *tegra,
struct tegra_drm_client *client);
extern int host1x_register_client(struct host1x_drm *host1x, extern int tegra_drm_init(struct tegra_drm *tegra, struct drm_device *drm);
struct host1x_client *client); extern int tegra_drm_exit(struct tegra_drm *tegra);
extern int host1x_unregister_client(struct host1x_drm *host1x,
struct host1x_client *client);
struct tegra_output; struct tegra_output;
struct tegra_dc { struct tegra_dc {
struct host1x_client client; struct host1x_client client;
spinlock_t lock;
struct host1x_drm *host1x;
struct device *dev; struct device *dev;
spinlock_t lock;
struct drm_crtc base; struct drm_crtc base;
int pipe; int pipe;
struct clk *clk; struct clk *clk;
void __iomem *regs; void __iomem *regs;
int irq; int irq;
...@@ -123,7 +108,8 @@ struct tegra_dc { ...@@ -123,7 +108,8 @@ struct tegra_dc {
struct drm_pending_vblank_event *event; struct drm_pending_vblank_event *event;
}; };
static inline struct tegra_dc *host1x_client_to_dc(struct host1x_client *client) static inline struct tegra_dc *
host1x_client_to_dc(struct host1x_client *client)
{ {
return container_of(client, struct tegra_dc, client); return container_of(client, struct tegra_dc, client);
} }
...@@ -162,6 +148,8 @@ struct tegra_dc_window { ...@@ -162,6 +148,8 @@ struct tegra_dc_window {
unsigned int format; unsigned int format;
unsigned int stride[2]; unsigned int stride[2];
unsigned long base[3]; unsigned long base[3];
bool bottom_up;
bool tiled;
}; };
/* from dc.c */ /* from dc.c */
...@@ -249,23 +237,34 @@ static inline int tegra_output_check_mode(struct tegra_output *output, ...@@ -249,23 +237,34 @@ static inline int tegra_output_check_mode(struct tegra_output *output,
return output ? -ENOSYS : -EINVAL; return output ? -ENOSYS : -EINVAL;
} }
/* from bus.c */
int drm_host1x_init(struct drm_driver *driver, struct host1x_device *device);
void drm_host1x_exit(struct drm_driver *driver, struct host1x_device *device);
/* from rgb.c */ /* from rgb.c */
extern int tegra_dc_rgb_probe(struct tegra_dc *dc); extern int tegra_dc_rgb_probe(struct tegra_dc *dc);
extern int tegra_dc_rgb_remove(struct tegra_dc *dc);
extern int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc); extern int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc);
extern int tegra_dc_rgb_exit(struct tegra_dc *dc); extern int tegra_dc_rgb_exit(struct tegra_dc *dc);
/* from output.c */ /* from output.c */
extern int tegra_output_parse_dt(struct tegra_output *output); extern int tegra_output_probe(struct tegra_output *output);
extern int tegra_output_remove(struct tegra_output *output);
extern int tegra_output_init(struct drm_device *drm, struct tegra_output *output); extern int tegra_output_init(struct drm_device *drm, struct tegra_output *output);
extern int tegra_output_exit(struct tegra_output *output); extern int tegra_output_exit(struct tegra_output *output);
/* from fb.c */ /* from fb.c */
struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer, struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
unsigned int index); unsigned int index);
bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer);
bool tegra_fb_is_tiled(struct drm_framebuffer *framebuffer);
extern int tegra_drm_fb_init(struct drm_device *drm); extern int tegra_drm_fb_init(struct drm_device *drm);
extern void tegra_drm_fb_exit(struct drm_device *drm); extern void tegra_drm_fb_exit(struct drm_device *drm);
extern void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev); extern void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev);
extern struct drm_driver tegra_drm_driver; extern struct platform_driver tegra_dc_driver;
extern struct platform_driver tegra_hdmi_driver;
extern struct platform_driver tegra_gr2d_driver;
extern struct platform_driver tegra_gr3d_driver;
#endif /* HOST1X_DRM_H */ #endif /* HOST1X_DRM_H */
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/module.h>
#include "drm.h" #include "drm.h"
#include "gem.h" #include "gem.h"
...@@ -36,6 +34,26 @@ struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer, ...@@ -36,6 +34,26 @@ struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
return fb->planes[index]; return fb->planes[index];
} }
bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer)
{
struct tegra_fb *fb = to_tegra_fb(framebuffer);
if (fb->planes[0]->flags & TEGRA_BO_BOTTOM_UP)
return true;
return false;
}
bool tegra_fb_is_tiled(struct drm_framebuffer *framebuffer)
{
struct tegra_fb *fb = to_tegra_fb(framebuffer);
if (fb->planes[0]->flags & TEGRA_BO_TILED)
return true;
return false;
}
static void tegra_fb_destroy(struct drm_framebuffer *framebuffer) static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
{ {
struct tegra_fb *fb = to_tegra_fb(framebuffer); struct tegra_fb *fb = to_tegra_fb(framebuffer);
...@@ -190,7 +208,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper, ...@@ -190,7 +208,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
size = cmd.pitches[0] * cmd.height; size = cmd.pitches[0] * cmd.height;
bo = tegra_bo_create(drm, size); bo = tegra_bo_create(drm, size, 0);
if (IS_ERR(bo)) if (IS_ERR(bo))
return PTR_ERR(bo); return PTR_ERR(bo);
...@@ -323,10 +341,10 @@ static void tegra_fbdev_free(struct tegra_fbdev *fbdev) ...@@ -323,10 +341,10 @@ static void tegra_fbdev_free(struct tegra_fbdev *fbdev)
static void tegra_fb_output_poll_changed(struct drm_device *drm) static void tegra_fb_output_poll_changed(struct drm_device *drm)
{ {
struct host1x_drm *host1x = drm->dev_private; struct tegra_drm *tegra = drm->dev_private;
if (host1x->fbdev) if (tegra->fbdev)
drm_fb_helper_hotplug_event(&host1x->fbdev->base); drm_fb_helper_hotplug_event(&tegra->fbdev->base);
} }
static const struct drm_mode_config_funcs tegra_drm_mode_funcs = { static const struct drm_mode_config_funcs tegra_drm_mode_funcs = {
...@@ -336,7 +354,7 @@ static const struct drm_mode_config_funcs tegra_drm_mode_funcs = { ...@@ -336,7 +354,7 @@ static const struct drm_mode_config_funcs tegra_drm_mode_funcs = {
int tegra_drm_fb_init(struct drm_device *drm) int tegra_drm_fb_init(struct drm_device *drm)
{ {
struct host1x_drm *host1x = drm->dev_private; struct tegra_drm *tegra = drm->dev_private;
struct tegra_fbdev *fbdev; struct tegra_fbdev *fbdev;
drm->mode_config.min_width = 0; drm->mode_config.min_width = 0;
...@@ -352,16 +370,16 @@ int tegra_drm_fb_init(struct drm_device *drm) ...@@ -352,16 +370,16 @@ int tegra_drm_fb_init(struct drm_device *drm)
if (IS_ERR(fbdev)) if (IS_ERR(fbdev))
return PTR_ERR(fbdev); return PTR_ERR(fbdev);
host1x->fbdev = fbdev; tegra->fbdev = fbdev;
return 0; return 0;
} }
void tegra_drm_fb_exit(struct drm_device *drm) void tegra_drm_fb_exit(struct drm_device *drm)
{ {
struct host1x_drm *host1x = drm->dev_private; struct tegra_drm *tegra = drm->dev_private;
tegra_fbdev_free(host1x->fbdev); tegra_fbdev_free(tegra->fbdev);
} }
void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev) void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev)
......
...@@ -18,25 +18,18 @@ ...@@ -18,25 +18,18 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/mm.h> #include <drm/tegra_drm.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/export.h>
#include <linux/dma-mapping.h>
#include <drm/drmP.h>
#include <drm/drm.h>
#include "gem.h" #include "gem.h"
static inline struct tegra_bo *host1x_to_drm_bo(struct host1x_bo *bo) static inline struct tegra_bo *host1x_to_tegra_bo(struct host1x_bo *bo)
{ {
return container_of(bo, struct tegra_bo, base); return container_of(bo, struct tegra_bo, base);
} }
static void tegra_bo_put(struct host1x_bo *bo) static void tegra_bo_put(struct host1x_bo *bo)
{ {
struct tegra_bo *obj = host1x_to_drm_bo(bo); struct tegra_bo *obj = host1x_to_tegra_bo(bo);
struct drm_device *drm = obj->gem.dev; struct drm_device *drm = obj->gem.dev;
mutex_lock(&drm->struct_mutex); mutex_lock(&drm->struct_mutex);
...@@ -46,7 +39,7 @@ static void tegra_bo_put(struct host1x_bo *bo) ...@@ -46,7 +39,7 @@ static void tegra_bo_put(struct host1x_bo *bo)
static dma_addr_t tegra_bo_pin(struct host1x_bo *bo, struct sg_table **sgt) static dma_addr_t tegra_bo_pin(struct host1x_bo *bo, struct sg_table **sgt)
{ {
struct tegra_bo *obj = host1x_to_drm_bo(bo); struct tegra_bo *obj = host1x_to_tegra_bo(bo);
return obj->paddr; return obj->paddr;
} }
...@@ -57,7 +50,7 @@ static void tegra_bo_unpin(struct host1x_bo *bo, struct sg_table *sgt) ...@@ -57,7 +50,7 @@ static void tegra_bo_unpin(struct host1x_bo *bo, struct sg_table *sgt)
static void *tegra_bo_mmap(struct host1x_bo *bo) static void *tegra_bo_mmap(struct host1x_bo *bo)
{ {
struct tegra_bo *obj = host1x_to_drm_bo(bo); struct tegra_bo *obj = host1x_to_tegra_bo(bo);
return obj->vaddr; return obj->vaddr;
} }
...@@ -68,7 +61,7 @@ static void tegra_bo_munmap(struct host1x_bo *bo, void *addr) ...@@ -68,7 +61,7 @@ static void tegra_bo_munmap(struct host1x_bo *bo, void *addr)
static void *tegra_bo_kmap(struct host1x_bo *bo, unsigned int page) static void *tegra_bo_kmap(struct host1x_bo *bo, unsigned int page)
{ {
struct tegra_bo *obj = host1x_to_drm_bo(bo); struct tegra_bo *obj = host1x_to_tegra_bo(bo);
return obj->vaddr + page * PAGE_SIZE; return obj->vaddr + page * PAGE_SIZE;
} }
...@@ -80,7 +73,7 @@ static void tegra_bo_kunmap(struct host1x_bo *bo, unsigned int page, ...@@ -80,7 +73,7 @@ static void tegra_bo_kunmap(struct host1x_bo *bo, unsigned int page,
static struct host1x_bo *tegra_bo_get(struct host1x_bo *bo) static struct host1x_bo *tegra_bo_get(struct host1x_bo *bo)
{ {
struct tegra_bo *obj = host1x_to_drm_bo(bo); struct tegra_bo *obj = host1x_to_tegra_bo(bo);
struct drm_device *drm = obj->gem.dev; struct drm_device *drm = obj->gem.dev;
mutex_lock(&drm->struct_mutex); mutex_lock(&drm->struct_mutex);
...@@ -106,7 +99,8 @@ static void tegra_bo_destroy(struct drm_device *drm, struct tegra_bo *bo) ...@@ -106,7 +99,8 @@ static void tegra_bo_destroy(struct drm_device *drm, struct tegra_bo *bo)
dma_free_writecombine(drm->dev, bo->gem.size, bo->vaddr, bo->paddr); dma_free_writecombine(drm->dev, bo->gem.size, bo->vaddr, bo->paddr);
} }
struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size) struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size,
unsigned long flags)
{ {
struct tegra_bo *bo; struct tegra_bo *bo;
int err; int err;
...@@ -135,6 +129,12 @@ struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size) ...@@ -135,6 +129,12 @@ struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size)
if (err) if (err)
goto err_mmap; goto err_mmap;
if (flags & DRM_TEGRA_GEM_CREATE_TILED)
bo->flags |= TEGRA_BO_TILED;
if (flags & DRM_TEGRA_GEM_CREATE_BOTTOM_UP)
bo->flags |= TEGRA_BO_BOTTOM_UP;
return bo; return bo;
err_mmap: err_mmap:
...@@ -149,14 +149,15 @@ struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size) ...@@ -149,14 +149,15 @@ struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size)
} }
struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file, struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
struct drm_device *drm, struct drm_device *drm,
unsigned int size, unsigned int size,
unsigned int *handle) unsigned long flags,
unsigned int *handle)
{ {
struct tegra_bo *bo; struct tegra_bo *bo;
int ret; int ret;
bo = tegra_bo_create(drm, size); bo = tegra_bo_create(drm, size, flags);
if (IS_ERR(bo)) if (IS_ERR(bo))
return bo; return bo;
...@@ -178,7 +179,6 @@ void tegra_bo_free_object(struct drm_gem_object *gem) ...@@ -178,7 +179,6 @@ void tegra_bo_free_object(struct drm_gem_object *gem)
struct tegra_bo *bo = to_tegra_bo(gem); struct tegra_bo *bo = to_tegra_bo(gem);
drm_gem_free_mmap_offset(gem); drm_gem_free_mmap_offset(gem);
drm_gem_object_release(gem); drm_gem_object_release(gem);
tegra_bo_destroy(gem->dev, bo); tegra_bo_destroy(gem->dev, bo);
...@@ -197,8 +197,8 @@ int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm, ...@@ -197,8 +197,8 @@ int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
if (args->size < args->pitch * args->height) if (args->size < args->pitch * args->height)
args->size = args->pitch * args->height; args->size = args->pitch * args->height;
bo = tegra_bo_create_with_handle(file, drm, args->size, bo = tegra_bo_create_with_handle(file, drm, args->size, 0,
&args->handle); &args->handle);
if (IS_ERR(bo)) if (IS_ERR(bo))
return PTR_ERR(bo); return PTR_ERR(bo);
......
...@@ -19,14 +19,18 @@ ...@@ -19,14 +19,18 @@
#ifndef __HOST1X_GEM_H #ifndef __HOST1X_GEM_H
#define __HOST1X_GEM_H #define __HOST1X_GEM_H
#include <linux/host1x.h>
#include <drm/drm.h> #include <drm/drm.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include "host1x_bo.h" #define TEGRA_BO_TILED (1 << 0)
#define TEGRA_BO_BOTTOM_UP (1 << 1)
struct tegra_bo { struct tegra_bo {
struct drm_gem_object gem; struct drm_gem_object gem;
struct host1x_bo base; struct host1x_bo base;
unsigned long flags;
dma_addr_t paddr; dma_addr_t paddr;
void *vaddr; void *vaddr;
}; };
...@@ -38,11 +42,13 @@ static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem) ...@@ -38,11 +42,13 @@ static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
extern const struct host1x_bo_ops tegra_bo_ops; extern const struct host1x_bo_ops tegra_bo_ops;
struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size); struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size,
unsigned long flags);
struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file, struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
struct drm_device *drm, struct drm_device *drm,
unsigned int size, unsigned int size,
unsigned int *handle); unsigned long flags,
unsigned int *handle);
void tegra_bo_free_object(struct drm_gem_object *gem); void tegra_bo_free_object(struct drm_gem_object *gem);
int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm, int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
struct drm_mode_create_dumb *args); struct drm_mode_create_dumb *args);
......
/*
* Copyright (C) 2013 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef TEGRA_GR2D_H
#define TEGRA_GR2D_H
#define GR2D_UA_BASE_ADDR 0x1a
#define GR2D_VA_BASE_ADDR 0x1b
#define GR2D_PAT_BASE_ADDR 0x26
#define GR2D_DSTA_BASE_ADDR 0x2b
#define GR2D_DSTB_BASE_ADDR 0x2c
#define GR2D_DSTC_BASE_ADDR 0x2d
#define GR2D_SRCA_BASE_ADDR 0x31
#define GR2D_SRCB_BASE_ADDR 0x32
#define GR2D_SRC_BASE_ADDR_SB 0x48
#define GR2D_DSTA_BASE_ADDR_SB 0x49
#define GR2D_DSTB_BASE_ADDR_SB 0x4a
#define GR2D_UA_BASE_ADDR_SB 0x4b
#define GR2D_VA_BASE_ADDR_SB 0x4c
#define GR2D_NUM_REGS 0x4d
#endif
/*
* Copyright (C) 2013 Avionic Design GmbH
* Copyright (C) 2013 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/clk.h>
#include <linux/host1x.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/tegra-powergate.h>
#include "drm.h"
#include "gem.h"
#include "gr3d.h"
struct gr3d {
struct tegra_drm_client client;
struct host1x_channel *channel;
struct clk *clk_secondary;
struct clk *clk;
DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS);
};
static inline struct gr3d *to_gr3d(struct tegra_drm_client *client)
{
return container_of(client, struct gr3d, client);
}
static int gr3d_init(struct host1x_client *client)
{
struct tegra_drm_client *drm = host1x_to_drm_client(client);
struct tegra_drm *tegra = dev_get_drvdata(client->parent);
unsigned long flags = HOST1X_SYNCPT_HAS_BASE;
struct gr3d *gr3d = to_gr3d(drm);
gr3d->channel = host1x_channel_request(client->dev);
if (!gr3d->channel)
return -ENOMEM;
client->syncpts[0] = host1x_syncpt_request(client->dev, flags);
if (!client->syncpts[0]) {
host1x_channel_free(gr3d->channel);
return -ENOMEM;
}
return tegra_drm_register_client(tegra, drm);
}
static int gr3d_exit(struct host1x_client *client)
{
struct tegra_drm_client *drm = host1x_to_drm_client(client);
struct tegra_drm *tegra = dev_get_drvdata(client->parent);
struct gr3d *gr3d = to_gr3d(drm);
int err;
err = tegra_drm_unregister_client(tegra, drm);
if (err < 0)
return err;
host1x_syncpt_free(client->syncpts[0]);
host1x_channel_free(gr3d->channel);
return 0;
}
static const struct host1x_client_ops gr3d_client_ops = {
.init = gr3d_init,
.exit = gr3d_exit,
};
static int gr3d_open_channel(struct tegra_drm_client *client,
struct tegra_drm_context *context)
{
struct gr3d *gr3d = to_gr3d(client);
context->channel = host1x_channel_get(gr3d->channel);
if (!context->channel)
return -ENOMEM;
return 0;
}
static void gr3d_close_channel(struct tegra_drm_context *context)
{
host1x_channel_put(context->channel);
}
static int gr3d_is_addr_reg(struct device *dev, u32 class, u32 offset)
{
struct gr3d *gr3d = dev_get_drvdata(dev);
switch (class) {
case HOST1X_CLASS_HOST1X:
if (offset == 0x2b)
return 1;
break;
case HOST1X_CLASS_GR3D:
if (offset >= GR3D_NUM_REGS)
break;
if (test_bit(offset, gr3d->addr_regs))
return 1;
break;
}
return 0;
}
static const struct tegra_drm_client_ops gr3d_ops = {
.open_channel = gr3d_open_channel,
.close_channel = gr3d_close_channel,
.is_addr_reg = gr3d_is_addr_reg,
.submit = tegra_drm_submit,
};
static const struct of_device_id tegra_gr3d_match[] = {
{ .compatible = "nvidia,tegra114-gr3d" },
{ .compatible = "nvidia,tegra30-gr3d" },
{ .compatible = "nvidia,tegra20-gr3d" },
{ }
};
static const u32 gr3d_addr_regs[] = {
GR3D_IDX_ATTRIBUTE( 0),
GR3D_IDX_ATTRIBUTE( 1),
GR3D_IDX_ATTRIBUTE( 2),
GR3D_IDX_ATTRIBUTE( 3),
GR3D_IDX_ATTRIBUTE( 4),
GR3D_IDX_ATTRIBUTE( 5),
GR3D_IDX_ATTRIBUTE( 6),
GR3D_IDX_ATTRIBUTE( 7),
GR3D_IDX_ATTRIBUTE( 8),
GR3D_IDX_ATTRIBUTE( 9),
GR3D_IDX_ATTRIBUTE(10),
GR3D_IDX_ATTRIBUTE(11),
GR3D_IDX_ATTRIBUTE(12),
GR3D_IDX_ATTRIBUTE(13),
GR3D_IDX_ATTRIBUTE(14),
GR3D_IDX_ATTRIBUTE(15),
GR3D_IDX_INDEX_BASE,
GR3D_QR_ZTAG_ADDR,
GR3D_QR_CTAG_ADDR,
GR3D_QR_CZ_ADDR,
GR3D_TEX_TEX_ADDR( 0),
GR3D_TEX_TEX_ADDR( 1),
GR3D_TEX_TEX_ADDR( 2),
GR3D_TEX_TEX_ADDR( 3),
GR3D_TEX_TEX_ADDR( 4),
GR3D_TEX_TEX_ADDR( 5),
GR3D_TEX_TEX_ADDR( 6),
GR3D_TEX_TEX_ADDR( 7),
GR3D_TEX_TEX_ADDR( 8),
GR3D_TEX_TEX_ADDR( 9),
GR3D_TEX_TEX_ADDR(10),
GR3D_TEX_TEX_ADDR(11),
GR3D_TEX_TEX_ADDR(12),
GR3D_TEX_TEX_ADDR(13),
GR3D_TEX_TEX_ADDR(14),
GR3D_TEX_TEX_ADDR(15),
GR3D_DW_MEMORY_OUTPUT_ADDRESS,
GR3D_GLOBAL_SURFADDR( 0),
GR3D_GLOBAL_SURFADDR( 1),
GR3D_GLOBAL_SURFADDR( 2),
GR3D_GLOBAL_SURFADDR( 3),
GR3D_GLOBAL_SURFADDR( 4),
GR3D_GLOBAL_SURFADDR( 5),
GR3D_GLOBAL_SURFADDR( 6),
GR3D_GLOBAL_SURFADDR( 7),
GR3D_GLOBAL_SURFADDR( 8),
GR3D_GLOBAL_SURFADDR( 9),
GR3D_GLOBAL_SURFADDR(10),
GR3D_GLOBAL_SURFADDR(11),
GR3D_GLOBAL_SURFADDR(12),
GR3D_GLOBAL_SURFADDR(13),
GR3D_GLOBAL_SURFADDR(14),
GR3D_GLOBAL_SURFADDR(15),
GR3D_GLOBAL_SPILLSURFADDR,
GR3D_GLOBAL_SURFOVERADDR( 0),
GR3D_GLOBAL_SURFOVERADDR( 1),
GR3D_GLOBAL_SURFOVERADDR( 2),
GR3D_GLOBAL_SURFOVERADDR( 3),
GR3D_GLOBAL_SURFOVERADDR( 4),
GR3D_GLOBAL_SURFOVERADDR( 5),
GR3D_GLOBAL_SURFOVERADDR( 6),
GR3D_GLOBAL_SURFOVERADDR( 7),
GR3D_GLOBAL_SURFOVERADDR( 8),
GR3D_GLOBAL_SURFOVERADDR( 9),
GR3D_GLOBAL_SURFOVERADDR(10),
GR3D_GLOBAL_SURFOVERADDR(11),
GR3D_GLOBAL_SURFOVERADDR(12),
GR3D_GLOBAL_SURFOVERADDR(13),
GR3D_GLOBAL_SURFOVERADDR(14),
GR3D_GLOBAL_SURFOVERADDR(15),
GR3D_GLOBAL_SAMP01SURFADDR( 0),
GR3D_GLOBAL_SAMP01SURFADDR( 1),
GR3D_GLOBAL_SAMP01SURFADDR( 2),
GR3D_GLOBAL_SAMP01SURFADDR( 3),
GR3D_GLOBAL_SAMP01SURFADDR( 4),
GR3D_GLOBAL_SAMP01SURFADDR( 5),
GR3D_GLOBAL_SAMP01SURFADDR( 6),
GR3D_GLOBAL_SAMP01SURFADDR( 7),
GR3D_GLOBAL_SAMP01SURFADDR( 8),
GR3D_GLOBAL_SAMP01SURFADDR( 9),
GR3D_GLOBAL_SAMP01SURFADDR(10),
GR3D_GLOBAL_SAMP01SURFADDR(11),
GR3D_GLOBAL_SAMP01SURFADDR(12),
GR3D_GLOBAL_SAMP01SURFADDR(13),
GR3D_GLOBAL_SAMP01SURFADDR(14),
GR3D_GLOBAL_SAMP01SURFADDR(15),
GR3D_GLOBAL_SAMP23SURFADDR( 0),
GR3D_GLOBAL_SAMP23SURFADDR( 1),
GR3D_GLOBAL_SAMP23SURFADDR( 2),
GR3D_GLOBAL_SAMP23SURFADDR( 3),
GR3D_GLOBAL_SAMP23SURFADDR( 4),
GR3D_GLOBAL_SAMP23SURFADDR( 5),
GR3D_GLOBAL_SAMP23SURFADDR( 6),
GR3D_GLOBAL_SAMP23SURFADDR( 7),
GR3D_GLOBAL_SAMP23SURFADDR( 8),
GR3D_GLOBAL_SAMP23SURFADDR( 9),
GR3D_GLOBAL_SAMP23SURFADDR(10),
GR3D_GLOBAL_SAMP23SURFADDR(11),
GR3D_GLOBAL_SAMP23SURFADDR(12),
GR3D_GLOBAL_SAMP23SURFADDR(13),
GR3D_GLOBAL_SAMP23SURFADDR(14),
GR3D_GLOBAL_SAMP23SURFADDR(15),
};
static int gr3d_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct host1x_syncpt **syncpts;
struct gr3d *gr3d;
unsigned int i;
int err;
gr3d = devm_kzalloc(&pdev->dev, sizeof(*gr3d), GFP_KERNEL);
if (!gr3d)
return -ENOMEM;
syncpts = devm_kzalloc(&pdev->dev, sizeof(*syncpts), GFP_KERNEL);
if (!syncpts)
return -ENOMEM;
gr3d->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(gr3d->clk)) {
dev_err(&pdev->dev, "cannot get clock\n");
return PTR_ERR(gr3d->clk);
}
if (of_device_is_compatible(np, "nvidia,tegra30-gr3d")) {
gr3d->clk_secondary = devm_clk_get(&pdev->dev, "3d2");
if (IS_ERR(gr3d->clk)) {
dev_err(&pdev->dev, "cannot get secondary clock\n");
return PTR_ERR(gr3d->clk);
}
}
err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_3D, gr3d->clk);
if (err < 0) {
dev_err(&pdev->dev, "failed to power up 3D unit\n");
return err;
}
if (gr3d->clk_secondary) {
err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_3D1,
gr3d->clk_secondary);
if (err < 0) {
dev_err(&pdev->dev,
"failed to power up secondary 3D unit\n");
return err;
}
}
INIT_LIST_HEAD(&gr3d->client.base.list);
gr3d->client.base.ops = &gr3d_client_ops;
gr3d->client.base.dev = &pdev->dev;
gr3d->client.base.class = HOST1X_CLASS_GR3D;
gr3d->client.base.syncpts = syncpts;
gr3d->client.base.num_syncpts = 1;
INIT_LIST_HEAD(&gr3d->client.list);
gr3d->client.ops = &gr3d_ops;
err = host1x_client_register(&gr3d->client.base);
if (err < 0) {
dev_err(&pdev->dev, "failed to register host1x client: %d\n",
err);
return err;
}
/* initialize address register map */
for (i = 0; i < ARRAY_SIZE(gr3d_addr_regs); i++)
set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
platform_set_drvdata(pdev, gr3d);
return 0;
}
static int gr3d_remove(struct platform_device *pdev)
{
struct gr3d *gr3d = platform_get_drvdata(pdev);
int err;
err = host1x_client_unregister(&gr3d->client.base);
if (err < 0) {
dev_err(&pdev->dev, "failed to unregister host1x client: %d\n",
err);
return err;
}
if (gr3d->clk_secondary) {
tegra_powergate_power_off(TEGRA_POWERGATE_3D1);
clk_disable_unprepare(gr3d->clk_secondary);
}
tegra_powergate_power_off(TEGRA_POWERGATE_3D);
clk_disable_unprepare(gr3d->clk);
return 0;
}
struct platform_driver tegra_gr3d_driver = {
.driver = {
.name = "tegra-gr3d",
.of_match_table = tegra_gr3d_match,
},
.probe = gr3d_probe,
.remove = gr3d_remove,
};
/*
* Copyright (C) 2013 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef TEGRA_GR3D_H
#define TEGRA_GR3D_H
#define GR3D_IDX_ATTRIBUTE(x) (0x100 + (x) * 2)
#define GR3D_IDX_INDEX_BASE 0x121
#define GR3D_QR_ZTAG_ADDR 0x415
#define GR3D_QR_CTAG_ADDR 0x417
#define GR3D_QR_CZ_ADDR 0x419
#define GR3D_TEX_TEX_ADDR(x) (0x710 + (x))
#define GR3D_DW_MEMORY_OUTPUT_ADDRESS 0x904
#define GR3D_GLOBAL_SURFADDR(x) (0xe00 + (x))
#define GR3D_GLOBAL_SPILLSURFADDR 0xe2a
#define GR3D_GLOBAL_SURFOVERADDR(x) (0xe30 + (x))
#define GR3D_GLOBAL_SAMP01SURFADDR(x) (0xe50 + (x))
#define GR3D_GLOBAL_SAMP23SURFADDR(x) (0xe60 + (x))
#define GR3D_NUM_REGS 0xe88
#endif
...@@ -233,7 +233,10 @@ ...@@ -233,7 +233,10 @@
#define DRIVE_CURRENT_LANE1(x) (((x) & 0x3f) << 8) #define DRIVE_CURRENT_LANE1(x) (((x) & 0x3f) << 8)
#define DRIVE_CURRENT_LANE2(x) (((x) & 0x3f) << 16) #define DRIVE_CURRENT_LANE2(x) (((x) & 0x3f) << 16)
#define DRIVE_CURRENT_LANE3(x) (((x) & 0x3f) << 24) #define DRIVE_CURRENT_LANE3(x) (((x) & 0x3f) << 24)
#define DRIVE_CURRENT_FUSE_OVERRIDE (1 << 31) #define DRIVE_CURRENT_LANE0_T114(x) (((x) & 0x7f) << 0)
#define DRIVE_CURRENT_LANE1_T114(x) (((x) & 0x7f) << 8)
#define DRIVE_CURRENT_LANE2_T114(x) (((x) & 0x7f) << 16)
#define DRIVE_CURRENT_LANE3_T114(x) (((x) & 0x7f) << 24)
#define DRIVE_CURRENT_1_500_mA 0x00 #define DRIVE_CURRENT_1_500_mA 0x00
#define DRIVE_CURRENT_1_875_mA 0x01 #define DRIVE_CURRENT_1_875_mA 0x01
...@@ -299,6 +302,79 @@ ...@@ -299,6 +302,79 @@
#define DRIVE_CURRENT_24_375_mA 0x3d #define DRIVE_CURRENT_24_375_mA 0x3d
#define DRIVE_CURRENT_24_750_mA 0x3e #define DRIVE_CURRENT_24_750_mA 0x3e
#define DRIVE_CURRENT_0_000_mA_T114 0x00
#define DRIVE_CURRENT_0_400_mA_T114 0x01
#define DRIVE_CURRENT_0_800_mA_T114 0x02
#define DRIVE_CURRENT_1_200_mA_T114 0x03
#define DRIVE_CURRENT_1_600_mA_T114 0x04
#define DRIVE_CURRENT_2_000_mA_T114 0x05
#define DRIVE_CURRENT_2_400_mA_T114 0x06
#define DRIVE_CURRENT_2_800_mA_T114 0x07
#define DRIVE_CURRENT_3_200_mA_T114 0x08
#define DRIVE_CURRENT_3_600_mA_T114 0x09
#define DRIVE_CURRENT_4_000_mA_T114 0x0a
#define DRIVE_CURRENT_4_400_mA_T114 0x0b
#define DRIVE_CURRENT_4_800_mA_T114 0x0c
#define DRIVE_CURRENT_5_200_mA_T114 0x0d
#define DRIVE_CURRENT_5_600_mA_T114 0x0e
#define DRIVE_CURRENT_6_000_mA_T114 0x0f
#define DRIVE_CURRENT_6_400_mA_T114 0x10
#define DRIVE_CURRENT_6_800_mA_T114 0x11
#define DRIVE_CURRENT_7_200_mA_T114 0x12
#define DRIVE_CURRENT_7_600_mA_T114 0x13
#define DRIVE_CURRENT_8_000_mA_T114 0x14
#define DRIVE_CURRENT_8_400_mA_T114 0x15
#define DRIVE_CURRENT_8_800_mA_T114 0x16
#define DRIVE_CURRENT_9_200_mA_T114 0x17
#define DRIVE_CURRENT_9_600_mA_T114 0x18
#define DRIVE_CURRENT_10_000_mA_T114 0x19
#define DRIVE_CURRENT_10_400_mA_T114 0x1a
#define DRIVE_CURRENT_10_800_mA_T114 0x1b
#define DRIVE_CURRENT_11_200_mA_T114 0x1c
#define DRIVE_CURRENT_11_600_mA_T114 0x1d
#define DRIVE_CURRENT_12_000_mA_T114 0x1e
#define DRIVE_CURRENT_12_400_mA_T114 0x1f
#define DRIVE_CURRENT_12_800_mA_T114 0x20
#define DRIVE_CURRENT_13_200_mA_T114 0x21
#define DRIVE_CURRENT_13_600_mA_T114 0x22
#define DRIVE_CURRENT_14_000_mA_T114 0x23
#define DRIVE_CURRENT_14_400_mA_T114 0x24
#define DRIVE_CURRENT_14_800_mA_T114 0x25
#define DRIVE_CURRENT_15_200_mA_T114 0x26
#define DRIVE_CURRENT_15_600_mA_T114 0x27
#define DRIVE_CURRENT_16_000_mA_T114 0x28
#define DRIVE_CURRENT_16_400_mA_T114 0x29
#define DRIVE_CURRENT_16_800_mA_T114 0x2a
#define DRIVE_CURRENT_17_200_mA_T114 0x2b
#define DRIVE_CURRENT_17_600_mA_T114 0x2c
#define DRIVE_CURRENT_18_000_mA_T114 0x2d
#define DRIVE_CURRENT_18_400_mA_T114 0x2e
#define DRIVE_CURRENT_18_800_mA_T114 0x2f
#define DRIVE_CURRENT_19_200_mA_T114 0x30
#define DRIVE_CURRENT_19_600_mA_T114 0x31
#define DRIVE_CURRENT_20_000_mA_T114 0x32
#define DRIVE_CURRENT_20_400_mA_T114 0x33
#define DRIVE_CURRENT_20_800_mA_T114 0x34
#define DRIVE_CURRENT_21_200_mA_T114 0x35
#define DRIVE_CURRENT_21_600_mA_T114 0x36
#define DRIVE_CURRENT_22_000_mA_T114 0x37
#define DRIVE_CURRENT_22_400_mA_T114 0x38
#define DRIVE_CURRENT_22_800_mA_T114 0x39
#define DRIVE_CURRENT_23_200_mA_T114 0x3a
#define DRIVE_CURRENT_23_600_mA_T114 0x3b
#define DRIVE_CURRENT_24_000_mA_T114 0x3c
#define DRIVE_CURRENT_24_400_mA_T114 0x3d
#define DRIVE_CURRENT_24_800_mA_T114 0x3e
#define DRIVE_CURRENT_25_200_mA_T114 0x3f
#define DRIVE_CURRENT_25_400_mA_T114 0x40
#define DRIVE_CURRENT_25_800_mA_T114 0x41
#define DRIVE_CURRENT_26_200_mA_T114 0x42
#define DRIVE_CURRENT_26_600_mA_T114 0x43
#define DRIVE_CURRENT_27_000_mA_T114 0x44
#define DRIVE_CURRENT_27_400_mA_T114 0x45
#define DRIVE_CURRENT_27_800_mA_T114 0x46
#define DRIVE_CURRENT_28_200_mA_T114 0x47
#define HDMI_NV_PDISP_AUDIO_DEBUG0 0x7f #define HDMI_NV_PDISP_AUDIO_DEBUG0 0x7f
#define HDMI_NV_PDISP_AUDIO_DEBUG1 0x80 #define HDMI_NV_PDISP_AUDIO_DEBUG1 0x80
#define HDMI_NV_PDISP_AUDIO_DEBUG2 0x81 #define HDMI_NV_PDISP_AUDIO_DEBUG2 0x81
...@@ -358,6 +434,23 @@ ...@@ -358,6 +434,23 @@
#define PE_CURRENT_7_0_mA 0xe #define PE_CURRENT_7_0_mA 0xe
#define PE_CURRENT_7_5_mA 0xf #define PE_CURRENT_7_5_mA 0xf
#define PE_CURRENT_0_mA_T114 0x0
#define PE_CURRENT_1_mA_T114 0x1
#define PE_CURRENT_2_mA_T114 0x2
#define PE_CURRENT_3_mA_T114 0x3
#define PE_CURRENT_4_mA_T114 0x4
#define PE_CURRENT_5_mA_T114 0x5
#define PE_CURRENT_6_mA_T114 0x6
#define PE_CURRENT_7_mA_T114 0x7
#define PE_CURRENT_8_mA_T114 0x8
#define PE_CURRENT_9_mA_T114 0x9
#define PE_CURRENT_10_mA_T114 0xa
#define PE_CURRENT_11_mA_T114 0xb
#define PE_CURRENT_12_mA_T114 0xc
#define PE_CURRENT_13_mA_T114 0xd
#define PE_CURRENT_14_mA_T114 0xe
#define PE_CURRENT_15_mA_T114 0xf
#define HDMI_NV_PDISP_KEY_CTRL 0x9a #define HDMI_NV_PDISP_KEY_CTRL 0x9a
#define HDMI_NV_PDISP_KEY_DEBUG0 0x9b #define HDMI_NV_PDISP_KEY_DEBUG0 0x9b
#define HDMI_NV_PDISP_KEY_DEBUG1 0x9c #define HDMI_NV_PDISP_KEY_DEBUG1 0x9c
...@@ -383,4 +476,61 @@ ...@@ -383,4 +476,61 @@
#define HDMI_NV_PDISP_SOR_AUDIO_AVAL_1920 0xc5 #define HDMI_NV_PDISP_SOR_AUDIO_AVAL_1920 0xc5
#define HDMI_NV_PDISP_SOR_AUDIO_AVAL_DEFAULT 0xc5 #define HDMI_NV_PDISP_SOR_AUDIO_AVAL_DEFAULT 0xc5
#define HDMI_NV_PDISP_SOR_IO_PEAK_CURRENT 0xd1
#define PEAK_CURRENT_LANE0(x) (((x) & 0x7f) << 0)
#define PEAK_CURRENT_LANE1(x) (((x) & 0x7f) << 8)
#define PEAK_CURRENT_LANE2(x) (((x) & 0x7f) << 16)
#define PEAK_CURRENT_LANE3(x) (((x) & 0x7f) << 24)
#define PEAK_CURRENT_0_000_mA 0x00
#define PEAK_CURRENT_0_200_mA 0x01
#define PEAK_CURRENT_0_400_mA 0x02
#define PEAK_CURRENT_0_600_mA 0x03
#define PEAK_CURRENT_0_800_mA 0x04
#define PEAK_CURRENT_1_000_mA 0x05
#define PEAK_CURRENT_1_200_mA 0x06
#define PEAK_CURRENT_1_400_mA 0x07
#define PEAK_CURRENT_1_600_mA 0x08
#define PEAK_CURRENT_1_800_mA 0x09
#define PEAK_CURRENT_2_000_mA 0x0a
#define PEAK_CURRENT_2_200_mA 0x0b
#define PEAK_CURRENT_2_400_mA 0x0c
#define PEAK_CURRENT_2_600_mA 0x0d
#define PEAK_CURRENT_2_800_mA 0x0e
#define PEAK_CURRENT_3_000_mA 0x0f
#define PEAK_CURRENT_3_200_mA 0x10
#define PEAK_CURRENT_3_400_mA 0x11
#define PEAK_CURRENT_3_600_mA 0x12
#define PEAK_CURRENT_3_800_mA 0x13
#define PEAK_CURRENT_4_000_mA 0x14
#define PEAK_CURRENT_4_200_mA 0x15
#define PEAK_CURRENT_4_400_mA 0x16
#define PEAK_CURRENT_4_600_mA 0x17
#define PEAK_CURRENT_4_800_mA 0x18
#define PEAK_CURRENT_5_000_mA 0x19
#define PEAK_CURRENT_5_200_mA 0x1a
#define PEAK_CURRENT_5_400_mA 0x1b
#define PEAK_CURRENT_5_600_mA 0x1c
#define PEAK_CURRENT_5_800_mA 0x1d
#define PEAK_CURRENT_6_000_mA 0x1e
#define PEAK_CURRENT_6_200_mA 0x1f
#define PEAK_CURRENT_6_400_mA 0x20
#define PEAK_CURRENT_6_600_mA 0x21
#define PEAK_CURRENT_6_800_mA 0x22
#define PEAK_CURRENT_7_000_mA 0x23
#define PEAK_CURRENT_7_200_mA 0x24
#define PEAK_CURRENT_7_400_mA 0x25
#define PEAK_CURRENT_7_600_mA 0x26
#define PEAK_CURRENT_7_800_mA 0x27
#define PEAK_CURRENT_8_000_mA 0x28
#define PEAK_CURRENT_8_200_mA 0x29
#define PEAK_CURRENT_8_400_mA 0x2a
#define PEAK_CURRENT_8_600_mA 0x2b
#define PEAK_CURRENT_8_800_mA 0x2c
#define PEAK_CURRENT_9_000_mA 0x2d
#define PEAK_CURRENT_9_200_mA 0x2e
#define PEAK_CURRENT_9_400_mA 0x2f
#define HDMI_NV_PDISP_SOR_PAD_CTLS0 0xd2
#endif /* TEGRA_HDMI_H */ #endif /* TEGRA_HDMI_H */
...@@ -7,9 +7,7 @@ ...@@ -7,9 +7,7 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/module.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/i2c.h>
#include "drm.h" #include "drm.h"
...@@ -81,10 +79,16 @@ tegra_connector_detect(struct drm_connector *connector, bool force) ...@@ -81,10 +79,16 @@ tegra_connector_detect(struct drm_connector *connector, bool force)
return status; return status;
} }
static void drm_connector_clear(struct drm_connector *connector)
{
memset(connector, 0, sizeof(*connector));
}
static void tegra_connector_destroy(struct drm_connector *connector) static void tegra_connector_destroy(struct drm_connector *connector)
{ {
drm_sysfs_connector_remove(connector); drm_sysfs_connector_remove(connector);
drm_connector_cleanup(connector); drm_connector_cleanup(connector);
drm_connector_clear(connector);
} }
static const struct drm_connector_funcs connector_funcs = { static const struct drm_connector_funcs connector_funcs = {
...@@ -94,9 +98,15 @@ static const struct drm_connector_funcs connector_funcs = { ...@@ -94,9 +98,15 @@ static const struct drm_connector_funcs connector_funcs = {
.destroy = tegra_connector_destroy, .destroy = tegra_connector_destroy,
}; };
static void drm_encoder_clear(struct drm_encoder *encoder)
{
memset(encoder, 0, sizeof(*encoder));
}
static void tegra_encoder_destroy(struct drm_encoder *encoder) static void tegra_encoder_destroy(struct drm_encoder *encoder)
{ {
drm_encoder_cleanup(encoder); drm_encoder_cleanup(encoder);
drm_encoder_clear(encoder);
} }
static const struct drm_encoder_funcs encoder_funcs = { static const struct drm_encoder_funcs encoder_funcs = {
...@@ -151,7 +161,7 @@ static irqreturn_t hpd_irq(int irq, void *data) ...@@ -151,7 +161,7 @@ static irqreturn_t hpd_irq(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
int tegra_output_parse_dt(struct tegra_output *output) int tegra_output_probe(struct tegra_output *output)
{ {
enum of_gpio_flags flags; enum of_gpio_flags flags;
struct device_node *ddc; struct device_node *ddc;
...@@ -181,14 +191,6 @@ int tegra_output_parse_dt(struct tegra_output *output) ...@@ -181,14 +191,6 @@ int tegra_output_parse_dt(struct tegra_output *output)
output->hpd_gpio = of_get_named_gpio_flags(output->of_node, output->hpd_gpio = of_get_named_gpio_flags(output->of_node,
"nvidia,hpd-gpio", 0, "nvidia,hpd-gpio", 0,
&flags); &flags);
return 0;
}
int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
{
int connector, encoder, err;
if (gpio_is_valid(output->hpd_gpio)) { if (gpio_is_valid(output->hpd_gpio)) {
unsigned long flags; unsigned long flags;
...@@ -202,7 +204,8 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output) ...@@ -202,7 +204,8 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
err = gpio_to_irq(output->hpd_gpio); err = gpio_to_irq(output->hpd_gpio);
if (err < 0) { if (err < 0) {
dev_err(output->dev, "gpio_to_irq(): %d\n", err); dev_err(output->dev, "gpio_to_irq(): %d\n", err);
goto free_hpd; gpio_free(output->hpd_gpio);
return err;
} }
output->hpd_irq = err; output->hpd_irq = err;
...@@ -215,12 +218,33 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output) ...@@ -215,12 +218,33 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
if (err < 0) { if (err < 0) {
dev_err(output->dev, "failed to request IRQ#%u: %d\n", dev_err(output->dev, "failed to request IRQ#%u: %d\n",
output->hpd_irq, err); output->hpd_irq, err);
goto free_hpd; gpio_free(output->hpd_gpio);
return err;
} }
output->connector.polled = DRM_CONNECTOR_POLL_HPD; output->connector.polled = DRM_CONNECTOR_POLL_HPD;
} }
return 0;
}
int tegra_output_remove(struct tegra_output *output)
{
if (gpio_is_valid(output->hpd_gpio)) {
free_irq(output->hpd_irq, output);
gpio_free(output->hpd_gpio);
}
if (output->ddc)
put_device(&output->ddc->dev);
return 0;
}
int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
{
int connector, encoder;
switch (output->type) { switch (output->type) {
case TEGRA_OUTPUT_RGB: case TEGRA_OUTPUT_RGB:
connector = DRM_MODE_CONNECTOR_LVDS; connector = DRM_MODE_CONNECTOR_LVDS;
...@@ -241,6 +265,7 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output) ...@@ -241,6 +265,7 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
drm_connector_init(drm, &output->connector, &connector_funcs, drm_connector_init(drm, &output->connector, &connector_funcs,
connector); connector);
drm_connector_helper_add(&output->connector, &connector_helper_funcs); drm_connector_helper_add(&output->connector, &connector_helper_funcs);
output->connector.dpms = DRM_MODE_DPMS_OFF;
drm_encoder_init(drm, &output->encoder, &encoder_funcs, encoder); drm_encoder_init(drm, &output->encoder, &encoder_funcs, encoder);
drm_encoder_helper_add(&output->encoder, &encoder_helper_funcs); drm_encoder_helper_add(&output->encoder, &encoder_helper_funcs);
...@@ -251,22 +276,9 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output) ...@@ -251,22 +276,9 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
output->encoder.possible_crtcs = 0x3; output->encoder.possible_crtcs = 0x3;
return 0; return 0;
free_hpd:
gpio_free(output->hpd_gpio);
return err;
} }
int tegra_output_exit(struct tegra_output *output) int tegra_output_exit(struct tegra_output *output)
{ {
if (gpio_is_valid(output->hpd_gpio)) {
free_irq(output->hpd_irq, output);
gpio_free(output->hpd_gpio);
}
if (output->ddc)
put_device(&output->ddc->dev);
return 0; return 0;
} }
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
*/ */
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include "drm.h" #include "drm.h"
#include "dc.h" #include "dc.h"
...@@ -150,7 +147,7 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) ...@@ -150,7 +147,7 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
rgb->output.dev = dc->dev; rgb->output.dev = dc->dev;
rgb->output.of_node = np; rgb->output.of_node = np;
err = tegra_output_parse_dt(&rgb->output); err = tegra_output_probe(&rgb->output);
if (err < 0) if (err < 0)
return err; return err;
...@@ -177,6 +174,20 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) ...@@ -177,6 +174,20 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
return 0; return 0;
} }
int tegra_dc_rgb_remove(struct tegra_dc *dc)
{
int err;
if (!dc->rgb)
return 0;
err = tegra_output_remove(dc->rgb);
if (err < 0)
return err;
return 0;
}
int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc) int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc)
{ {
struct tegra_rgb *rgb = to_rgb(dc->rgb); struct tegra_rgb *rgb = to_rgb(dc->rgb);
......
...@@ -19,6 +19,4 @@ config TEGRA_HOST1X_FIREWALL ...@@ -19,6 +19,4 @@ config TEGRA_HOST1X_FIREWALL
If unsure, choose Y. If unsure, choose Y.
source "drivers/gpu/host1x/drm/Kconfig"
endif endif
ccflags-y = -Idrivers/gpu/host1x
host1x-y = \ host1x-y = \
bus.o \
syncpt.o \ syncpt.o \
dev.o \ dev.o \
intr.o \ intr.o \
...@@ -8,13 +7,7 @@ host1x-y = \ ...@@ -8,13 +7,7 @@ host1x-y = \
channel.o \ channel.o \
job.o \ job.o \
debug.o \ debug.o \
hw/host1x01.o hw/host1x01.o \
hw/host1x02.o
ccflags-y += -Iinclude/drm
ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG
host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o
host1x-$(CONFIG_DRM_TEGRA) += drm/output.o drm/rgb.o drm/hdmi.o
host1x-$(CONFIG_DRM_TEGRA) += drm/gem.o
host1x-$(CONFIG_DRM_TEGRA) += drm/gr2d.o
obj-$(CONFIG_TEGRA_HOST1X) += host1x.o obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
This diff is collapsed.
/* /*
* Copyright (c) 2013, NVIDIA Corporation. * Copyright (C) 2012 Avionic Design GmbH
* Copyright (C) 2012-2013, NVIDIA Corporation
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
...@@ -14,22 +15,15 @@ ...@@ -14,22 +15,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef HOST1X_CLIENT_H #ifndef HOST1X_BUS_H
#define HOST1X_CLIENT_H #define HOST1X_BUS_H
struct device; struct host1x;
struct platform_device;
#ifdef CONFIG_DRM_TEGRA int host1x_bus_init(void);
int host1x_drm_alloc(struct platform_device *pdev); void host1x_bus_exit(void);
#else
static inline int host1x_drm_alloc(struct platform_device *pdev)
{
return 0;
}
#endif
void host1x_set_drm_data(struct device *dev, void *data); int host1x_register(struct host1x *host1x);
void *host1x_get_drm_data(struct device *dev); int host1x_unregister(struct host1x *host1x);
#endif #endif
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/host1x.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/kfifo.h> #include <linux/kfifo.h>
...@@ -30,7 +31,6 @@ ...@@ -30,7 +31,6 @@
#include "channel.h" #include "channel.h"
#include "dev.h" #include "dev.h"
#include "debug.h" #include "debug.h"
#include "host1x_bo.h"
#include "job.h" #include "job.h"
/* /*
......
...@@ -40,12 +40,6 @@ struct host1x_channel { ...@@ -40,12 +40,6 @@ struct host1x_channel {
/* channel list operations */ /* channel list operations */
int host1x_channel_list_init(struct host1x *host); int host1x_channel_list_init(struct host1x *host);
struct host1x_channel *host1x_channel_request(struct device *dev);
void host1x_channel_free(struct host1x_channel *channel);
struct host1x_channel *host1x_channel_get(struct host1x_channel *channel);
void host1x_channel_put(struct host1x_channel *channel);
int host1x_job_submit(struct host1x_job *job);
#define host1x_for_each_channel(host, channel) \ #define host1x_for_each_channel(host, channel) \
list_for_each_entry(channel, &host->chlist.list, list) list_for_each_entry(channel, &host->chlist.list, list)
......
...@@ -27,24 +27,13 @@ ...@@ -27,24 +27,13 @@
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/host1x.h> #include <trace/events/host1x.h>
#include "bus.h"
#include "dev.h" #include "dev.h"
#include "intr.h" #include "intr.h"
#include "channel.h" #include "channel.h"
#include "debug.h" #include "debug.h"
#include "hw/host1x01.h" #include "hw/host1x01.h"
#include "host1x_client.h" #include "hw/host1x02.h"
void host1x_set_drm_data(struct device *dev, void *data)
{
struct host1x *host1x = dev_get_drvdata(dev);
host1x->drm_data = data;
}
void *host1x_get_drm_data(struct device *dev)
{
struct host1x *host1x = dev_get_drvdata(dev);
return host1x ? host1x->drm_data : NULL;
}
void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r) void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
{ {
...@@ -79,7 +68,17 @@ static const struct host1x_info host1x01_info = { ...@@ -79,7 +68,17 @@ static const struct host1x_info host1x01_info = {
.sync_offset = 0x3000, .sync_offset = 0x3000,
}; };
static const struct host1x_info host1x02_info = {
.nb_channels = 9,
.nb_pts = 32,
.nb_mlocks = 16,
.nb_bases = 12,
.init = host1x02_init,
.sync_offset = 0x3000,
};
static struct of_device_id host1x_of_match[] = { static struct of_device_id host1x_of_match[] = {
{ .compatible = "nvidia,tegra114-host1x", .data = &host1x02_info, },
{ .compatible = "nvidia,tegra30-host1x", .data = &host1x01_info, }, { .compatible = "nvidia,tegra30-host1x", .data = &host1x01_info, },
{ .compatible = "nvidia,tegra20-host1x", .data = &host1x01_info, }, { .compatible = "nvidia,tegra20-host1x", .data = &host1x01_info, },
{ }, { },
...@@ -114,6 +113,9 @@ static int host1x_probe(struct platform_device *pdev) ...@@ -114,6 +113,9 @@ static int host1x_probe(struct platform_device *pdev)
if (!host) if (!host)
return -ENOMEM; return -ENOMEM;
mutex_init(&host->devices_lock);
INIT_LIST_HEAD(&host->devices);
INIT_LIST_HEAD(&host->list);
host->dev = &pdev->dev; host->dev = &pdev->dev;
host->info = id->data; host->info = id->data;
...@@ -152,7 +154,7 @@ static int host1x_probe(struct platform_device *pdev) ...@@ -152,7 +154,7 @@ static int host1x_probe(struct platform_device *pdev)
err = host1x_syncpt_init(host); err = host1x_syncpt_init(host);
if (err) { if (err) {
dev_err(&pdev->dev, "failed to initialize syncpts\n"); dev_err(&pdev->dev, "failed to initialize syncpts\n");
return err; goto fail_unprepare_disable;
} }
err = host1x_intr_init(host, syncpt_irq); err = host1x_intr_init(host, syncpt_irq);
...@@ -163,19 +165,26 @@ static int host1x_probe(struct platform_device *pdev) ...@@ -163,19 +165,26 @@ static int host1x_probe(struct platform_device *pdev)
host1x_debug_init(host); host1x_debug_init(host);
host1x_drm_alloc(pdev); err = host1x_register(host);
if (err < 0)
goto fail_deinit_intr;
return 0; return 0;
fail_deinit_intr:
host1x_intr_deinit(host);
fail_deinit_syncpt: fail_deinit_syncpt:
host1x_syncpt_deinit(host); host1x_syncpt_deinit(host);
fail_unprepare_disable:
clk_disable_unprepare(host->clk);
return err; return err;
} }
static int __exit host1x_remove(struct platform_device *pdev) static int host1x_remove(struct platform_device *pdev)
{ {
struct host1x *host = platform_get_drvdata(pdev); struct host1x *host = platform_get_drvdata(pdev);
host1x_unregister(host);
host1x_intr_deinit(host); host1x_intr_deinit(host);
host1x_syncpt_deinit(host); host1x_syncpt_deinit(host);
clk_disable_unprepare(host->clk); clk_disable_unprepare(host->clk);
...@@ -184,59 +193,36 @@ static int __exit host1x_remove(struct platform_device *pdev) ...@@ -184,59 +193,36 @@ static int __exit host1x_remove(struct platform_device *pdev)
} }
static struct platform_driver tegra_host1x_driver = { static struct platform_driver tegra_host1x_driver = {
.probe = host1x_probe,
.remove = __exit_p(host1x_remove),
.driver = { .driver = {
.owner = THIS_MODULE,
.name = "tegra-host1x", .name = "tegra-host1x",
.of_match_table = host1x_of_match, .of_match_table = host1x_of_match,
}, },
.probe = host1x_probe,
.remove = host1x_remove,
}; };
static int __init tegra_host1x_init(void) static int __init tegra_host1x_init(void)
{ {
int err; int err;
err = platform_driver_register(&tegra_host1x_driver); err = host1x_bus_init();
if (err < 0) if (err < 0)
return err; return err;
#ifdef CONFIG_DRM_TEGRA err = platform_driver_register(&tegra_host1x_driver);
err = platform_driver_register(&tegra_dc_driver); if (err < 0) {
if (err < 0) host1x_bus_exit();
goto unregister_host1x; return err;
}
err = platform_driver_register(&tegra_hdmi_driver);
if (err < 0)
goto unregister_dc;
err = platform_driver_register(&tegra_gr2d_driver);
if (err < 0)
goto unregister_hdmi;
#endif
return 0; return 0;
#ifdef CONFIG_DRM_TEGRA
unregister_hdmi:
platform_driver_unregister(&tegra_hdmi_driver);
unregister_dc:
platform_driver_unregister(&tegra_dc_driver);
unregister_host1x:
platform_driver_unregister(&tegra_host1x_driver);
return err;
#endif
} }
module_init(tegra_host1x_init); module_init(tegra_host1x_init);
static void __exit tegra_host1x_exit(void) static void __exit tegra_host1x_exit(void)
{ {
#ifdef CONFIG_DRM_TEGRA
platform_driver_unregister(&tegra_gr2d_driver);
platform_driver_unregister(&tegra_hdmi_driver);
platform_driver_unregister(&tegra_dc_driver);
#endif
platform_driver_unregister(&tegra_host1x_driver); platform_driver_unregister(&tegra_host1x_driver);
host1x_bus_exit();
} }
module_exit(tegra_host1x_exit); module_exit(tegra_host1x_exit);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "job.h" #include "job.h"
struct host1x_syncpt; struct host1x_syncpt;
struct host1x_syncpt_base;
struct host1x_channel; struct host1x_channel;
struct host1x_cdma; struct host1x_cdma;
struct host1x_job; struct host1x_job;
...@@ -102,6 +103,7 @@ struct host1x { ...@@ -102,6 +103,7 @@ struct host1x {
void __iomem *regs; void __iomem *regs;
struct host1x_syncpt *syncpt; struct host1x_syncpt *syncpt;
struct host1x_syncpt_base *bases;
struct device *dev; struct device *dev;
struct clk *clk; struct clk *clk;
...@@ -125,7 +127,10 @@ struct host1x { ...@@ -125,7 +127,10 @@ struct host1x {
struct dentry *debugfs; struct dentry *debugfs;
void *drm_data; struct mutex devices_lock;
struct list_head devices;
struct list_head list;
}; };
void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v); void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v);
...@@ -301,8 +306,4 @@ static inline void host1x_hw_show_mlocks(struct host1x *host, struct output *o) ...@@ -301,8 +306,4 @@ static inline void host1x_hw_show_mlocks(struct host1x *host, struct output *o)
host->debug_op->show_mlocks(host, o); host->debug_op->show_mlocks(host, o);
} }
extern struct platform_driver tegra_dc_driver;
extern struct platform_driver tegra_hdmi_driver;
extern struct platform_driver tegra_gr2d_driver;
#endif #endif
/*
* Tegra host1x Memory Management Abstraction header
*
* Copyright (c) 2012-2013, NVIDIA Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _HOST1X_BO_H
#define _HOST1X_BO_H
struct host1x_bo;
struct host1x_bo_ops {
struct host1x_bo *(*get)(struct host1x_bo *bo);
void (*put)(struct host1x_bo *bo);
dma_addr_t (*pin)(struct host1x_bo *bo, struct sg_table **sgt);
void (*unpin)(struct host1x_bo *bo, struct sg_table *sgt);
void *(*mmap)(struct host1x_bo *bo);
void (*munmap)(struct host1x_bo *bo, void *addr);
void *(*kmap)(struct host1x_bo *bo, unsigned int pagenum);
void (*kunmap)(struct host1x_bo *bo, unsigned int pagenum, void *addr);
};
struct host1x_bo {
const struct host1x_bo_ops *ops;
};
static inline void host1x_bo_init(struct host1x_bo *bo,
const struct host1x_bo_ops *ops)
{
bo->ops = ops;
}
static inline struct host1x_bo *host1x_bo_get(struct host1x_bo *bo)
{
return bo->ops->get(bo);
}
static inline void host1x_bo_put(struct host1x_bo *bo)
{
bo->ops->put(bo);
}
static inline dma_addr_t host1x_bo_pin(struct host1x_bo *bo,
struct sg_table **sgt)
{
return bo->ops->pin(bo, sgt);
}
static inline void host1x_bo_unpin(struct host1x_bo *bo, struct sg_table *sgt)
{
bo->ops->unpin(bo, sgt);
}
static inline void *host1x_bo_mmap(struct host1x_bo *bo)
{
return bo->ops->mmap(bo);
}
static inline void host1x_bo_munmap(struct host1x_bo *bo, void *addr)
{
bo->ops->munmap(bo, addr);
}
static inline void *host1x_bo_kmap(struct host1x_bo *bo, unsigned int pagenum)
{
return bo->ops->kmap(bo, pagenum);
}
static inline void host1x_bo_kunmap(struct host1x_bo *bo,
unsigned int pagenum, void *addr)
{
bo->ops->kunmap(bo, pagenum, addr);
}
#endif
ccflags-y = -Idrivers/gpu/host1x
host1x-hw-objs = \
host1x01.o
obj-$(CONFIG_TEGRA_HOST1X) += host1x-hw.o
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include "cdma.h" #include "../cdma.h"
#include "channel.h" #include "../channel.h"
#include "dev.h" #include "../dev.h"
#include "debug.h" #include "../debug.h"
/* /*
* Put the restart at the end of pushbuffer memor * Put the restart at the end of pushbuffer memor
......
...@@ -16,15 +16,15 @@ ...@@ -16,15 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/host1x.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <trace/events/host1x.h> #include <trace/events/host1x.h>
#include "host1x.h" #include "../channel.h"
#include "host1x_bo.h" #include "../dev.h"
#include "channel.h" #include "../intr.h"
#include "dev.h" #include "../job.h"
#include "intr.h"
#include "job.h"
#define HOST1X_CHANNEL_SIZE 16384 #define HOST1X_CHANNEL_SIZE 16384
#define TRACE_MAX_LENGTH 128U #define TRACE_MAX_LENGTH 128U
...@@ -67,6 +67,22 @@ static void submit_gathers(struct host1x_job *job) ...@@ -67,6 +67,22 @@ static void submit_gathers(struct host1x_job *job)
} }
} }
static inline void synchronize_syncpt_base(struct host1x_job *job)
{
struct host1x *host = dev_get_drvdata(job->channel->dev->parent);
struct host1x_syncpt *sp = host->syncpt + job->syncpt_id;
u32 id, value;
value = host1x_syncpt_read_max(sp);
id = sp->base->id;
host1x_cdma_push(&job->channel->cdma,
host1x_opcode_setclass(HOST1X_CLASS_HOST1X,
HOST1X_UCLASS_LOAD_SYNCPT_BASE, 1),
HOST1X_UCLASS_LOAD_SYNCPT_BASE_BASE_INDX_F(id) |
HOST1X_UCLASS_LOAD_SYNCPT_BASE_VALUE_F(value));
}
static int channel_submit(struct host1x_job *job) static int channel_submit(struct host1x_job *job)
{ {
struct host1x_channel *ch = job->channel; struct host1x_channel *ch = job->channel;
...@@ -118,6 +134,10 @@ static int channel_submit(struct host1x_job *job) ...@@ -118,6 +134,10 @@ static int channel_submit(struct host1x_job *job)
host1x_syncpt_read_max(sp))); host1x_syncpt_read_max(sp)));
} }
/* Synchronize base register to allow using it for relative waiting */
if (sp->base)
synchronize_syncpt_base(job);
syncval = host1x_syncpt_incr_max(sp, user_syncpt_incrs); syncval = host1x_syncpt_incr_max(sp, user_syncpt_incrs);
job->syncpt_end = syncval; job->syncpt_end = syncval;
......
...@@ -15,18 +15,10 @@ ...@@ -15,18 +15,10 @@
* *
*/ */
#include <linux/debugfs.h> #include "../dev.h"
#include <linux/seq_file.h> #include "../debug.h"
#include <linux/mm.h> #include "../cdma.h"
#include <linux/scatterlist.h> #include "../channel.h"
#include <linux/io.h>
#include "dev.h"
#include "debug.h"
#include "cdma.h"
#include "channel.h"
#include "host1x_bo.h"
#define HOST1X_DEBUG_MAX_PAGE_OFFSET 102400 #define HOST1X_DEBUG_MAX_PAGE_OFFSET 102400
......
...@@ -17,17 +17,17 @@ ...@@ -17,17 +17,17 @@
*/ */
/* include hw specification */ /* include hw specification */
#include "hw/host1x01.h" #include "host1x01.h"
#include "hw/host1x01_hardware.h" #include "host1x01_hardware.h"
/* include code */ /* include code */
#include "hw/cdma_hw.c" #include "cdma_hw.c"
#include "hw/channel_hw.c" #include "channel_hw.c"
#include "hw/debug_hw.c" #include "debug_hw.c"
#include "hw/intr_hw.c" #include "intr_hw.c"
#include "hw/syncpt_hw.c" #include "syncpt_hw.c"
#include "dev.h" #include "../dev.h"
int host1x01_init(struct host1x *host) int host1x01_init(struct host1x *host)
{ {
......
/*
* Host1x init for Tegra114 SoCs
*
* Copyright (c) 2013 NVIDIA Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* include hw specification */
#include "host1x01.h"
#include "host1x01_hardware.h"
/* include code */
#include "cdma_hw.c"
#include "channel_hw.c"
#include "debug_hw.c"
#include "intr_hw.c"
#include "syncpt_hw.c"
#include "../dev.h"
int host1x02_init(struct host1x *host)
{
host->channel_op = &host1x_channel_ops;
host->cdma_op = &host1x_cdma_ops;
host->cdma_pb_op = &host1x_pushbuffer_ops;
host->syncpt_op = &host1x_syncpt_ops;
host->intr_op = &host1x_intr_ops;
host->debug_op = &host1x_debug_ops;
return 0;
}
/* /*
* Tegra host1x driver * Host1x init for Tegra114 SoCs
* *
* Copyright (c) 2009-2013, NVIDIA Corporation. All rights reserved. * Copyright (c) 2013 NVIDIA Corporation.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify it
* it under the terms of the GNU General Public License as published by * under the terms and conditions of the GNU General Public License,
* the Free Software Foundation; either version 2 of the License, or * version 2, as published by the Free Software Foundation.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License
* with this program; if not, write to the Free Software Foundation, Inc., * along with this program. If not, see <http://www.gnu.org/licenses/>.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#ifndef __LINUX_HOST1X_H #ifndef HOST1X_HOST1X02_H
#define __LINUX_HOST1X_H #define HOST1X_HOST1X02_H
enum host1x_class { struct host1x;
HOST1X_CLASS_HOST1X = 0x1,
HOST1X_CLASS_GR2D = 0x51, int host1x02_init(struct host1x *host);
HOST1X_CLASS_GR2D_SB = 0x52
};
#endif #endif
...@@ -111,6 +111,12 @@ static inline u32 host1x_uclass_wait_syncpt_base_offset_f(u32 v) ...@@ -111,6 +111,12 @@ static inline u32 host1x_uclass_wait_syncpt_base_offset_f(u32 v)
} }
#define HOST1X_UCLASS_WAIT_SYNCPT_BASE_OFFSET_F(v) \ #define HOST1X_UCLASS_WAIT_SYNCPT_BASE_OFFSET_F(v) \
host1x_uclass_wait_syncpt_base_offset_f(v) host1x_uclass_wait_syncpt_base_offset_f(v)
static inline u32 host1x_uclass_load_syncpt_base_r(void)
{
return 0xb;
}
#define HOST1X_UCLASS_LOAD_SYNCPT_BASE \
host1x_uclass_load_syncpt_base_r()
static inline u32 host1x_uclass_load_syncpt_base_base_indx_f(u32 v) static inline u32 host1x_uclass_load_syncpt_base_base_indx_f(u32 v)
{ {
return (v & 0xff) << 24; return (v & 0xff) << 24;
......
/*
* Copyright (c) 2013 NVIDIA Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* Function naming determines intended use:
*
* <x>_r(void) : Returns the offset for register <x>.
*
* <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
*
* <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
*
* <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
* and masked to place it at field <y> of register <x>. This value
* can be |'d with others to produce a full register value for
* register <x>.
*
* <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
* value can be ~'d and then &'d to clear the value of field <y> for
* register <x>.
*
* <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
* to place it at field <y> of register <x>. This value can be |'d
* with others to produce a full register value for <x>.
*
* <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
* <x> value 'r' after being shifted to place its LSB at bit 0.
* This value is suitable for direct comparison with other unshifted
* values appropriate for use in field <y> of register <x>.
*
* <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
* field <y> of register <x>. This value is suitable for direct
* comparison with unshifted values appropriate for use in field <y>
* of register <x>.
*/
#ifndef HOST1X_HW_HOST1X02_CHANNEL_H
#define HOST1X_HW_HOST1X02_CHANNEL_H
static inline u32 host1x_channel_fifostat_r(void)
{
return 0x0;
}
#define HOST1X_CHANNEL_FIFOSTAT \
host1x_channel_fifostat_r()
static inline u32 host1x_channel_fifostat_cfempty_v(u32 r)
{
return (r >> 11) & 0x1;
}
#define HOST1X_CHANNEL_FIFOSTAT_CFEMPTY_V(r) \
host1x_channel_fifostat_cfempty_v(r)
static inline u32 host1x_channel_dmastart_r(void)
{
return 0x14;
}
#define HOST1X_CHANNEL_DMASTART \
host1x_channel_dmastart_r()
static inline u32 host1x_channel_dmaput_r(void)
{
return 0x18;
}
#define HOST1X_CHANNEL_DMAPUT \
host1x_channel_dmaput_r()
static inline u32 host1x_channel_dmaget_r(void)
{
return 0x1c;
}
#define HOST1X_CHANNEL_DMAGET \
host1x_channel_dmaget_r()
static inline u32 host1x_channel_dmaend_r(void)
{
return 0x20;
}
#define HOST1X_CHANNEL_DMAEND \
host1x_channel_dmaend_r()
static inline u32 host1x_channel_dmactrl_r(void)
{
return 0x24;
}
#define HOST1X_CHANNEL_DMACTRL \
host1x_channel_dmactrl_r()
static inline u32 host1x_channel_dmactrl_dmastop(void)
{
return 1 << 0;
}
#define HOST1X_CHANNEL_DMACTRL_DMASTOP \
host1x_channel_dmactrl_dmastop()
static inline u32 host1x_channel_dmactrl_dmastop_v(u32 r)
{
return (r >> 0) & 0x1;
}
#define HOST1X_CHANNEL_DMACTRL_DMASTOP_V(r) \
host1x_channel_dmactrl_dmastop_v(r)
static inline u32 host1x_channel_dmactrl_dmagetrst(void)
{
return 1 << 1;
}
#define HOST1X_CHANNEL_DMACTRL_DMAGETRST \
host1x_channel_dmactrl_dmagetrst()
static inline u32 host1x_channel_dmactrl_dmainitget(void)
{
return 1 << 2;
}
#define HOST1X_CHANNEL_DMACTRL_DMAINITGET \
host1x_channel_dmactrl_dmainitget()
#endif
/*
* Copyright (c) 2013 NVIDIA Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* Function naming determines intended use:
*
* <x>_r(void) : Returns the offset for register <x>.
*
* <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
*
* <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
*
* <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
* and masked to place it at field <y> of register <x>. This value
* can be |'d with others to produce a full register value for
* register <x>.
*
* <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
* value can be ~'d and then &'d to clear the value of field <y> for
* register <x>.
*
* <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
* to place it at field <y> of register <x>. This value can be |'d
* with others to produce a full register value for <x>.
*
* <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
* <x> value 'r' after being shifted to place its LSB at bit 0.
* This value is suitable for direct comparison with other unshifted
* values appropriate for use in field <y> of register <x>.
*
* <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
* field <y> of register <x>. This value is suitable for direct
* comparison with unshifted values appropriate for use in field <y>
* of register <x>.
*/
#ifndef HOST1X_HW_HOST1X02_SYNC_H
#define HOST1X_HW_HOST1X02_SYNC_H
#define REGISTER_STRIDE 4
static inline u32 host1x_sync_syncpt_r(unsigned int id)
{
return 0x400 + id * REGISTER_STRIDE;
}
#define HOST1X_SYNC_SYNCPT(id) \
host1x_sync_syncpt_r(id)
static inline u32 host1x_sync_syncpt_thresh_cpu0_int_status_r(unsigned int id)
{
return 0x40 + id * REGISTER_STRIDE;
}
#define HOST1X_SYNC_SYNCPT_THRESH_CPU0_INT_STATUS(id) \
host1x_sync_syncpt_thresh_cpu0_int_status_r(id)
static inline u32 host1x_sync_syncpt_thresh_int_disable_r(unsigned int id)
{
return 0x60 + id * REGISTER_STRIDE;
}
#define HOST1X_SYNC_SYNCPT_THRESH_INT_DISABLE(id) \
host1x_sync_syncpt_thresh_int_disable_r(id)
static inline u32 host1x_sync_syncpt_thresh_int_enable_cpu0_r(unsigned int id)
{
return 0x68 + id * REGISTER_STRIDE;
}
#define HOST1X_SYNC_SYNCPT_THRESH_INT_ENABLE_CPU0(id) \
host1x_sync_syncpt_thresh_int_enable_cpu0_r(id)
static inline u32 host1x_sync_cf_setup_r(unsigned int channel)
{
return 0x80 + channel * REGISTER_STRIDE;
}
#define HOST1X_SYNC_CF_SETUP(channel) \
host1x_sync_cf_setup_r(channel)
static inline u32 host1x_sync_cf_setup_base_v(u32 r)
{
return (r >> 0) & 0x3ff;
}
#define HOST1X_SYNC_CF_SETUP_BASE_V(r) \
host1x_sync_cf_setup_base_v(r)
static inline u32 host1x_sync_cf_setup_limit_v(u32 r)
{
return (r >> 16) & 0x3ff;
}
#define HOST1X_SYNC_CF_SETUP_LIMIT_V(r) \
host1x_sync_cf_setup_limit_v(r)
static inline u32 host1x_sync_cmdproc_stop_r(void)
{
return 0xac;
}
#define HOST1X_SYNC_CMDPROC_STOP \
host1x_sync_cmdproc_stop_r()
static inline u32 host1x_sync_ch_teardown_r(void)
{
return 0xb0;
}
#define HOST1X_SYNC_CH_TEARDOWN \
host1x_sync_ch_teardown_r()
static inline u32 host1x_sync_usec_clk_r(void)
{
return 0x1a4;
}
#define HOST1X_SYNC_USEC_CLK \
host1x_sync_usec_clk_r()
static inline u32 host1x_sync_ctxsw_timeout_cfg_r(void)
{
return 0x1a8;
}
#define HOST1X_SYNC_CTXSW_TIMEOUT_CFG \
host1x_sync_ctxsw_timeout_cfg_r()
static inline u32 host1x_sync_ip_busy_timeout_r(void)
{
return 0x1bc;
}
#define HOST1X_SYNC_IP_BUSY_TIMEOUT \
host1x_sync_ip_busy_timeout_r()
static inline u32 host1x_sync_mlock_owner_r(unsigned int id)
{
return 0x340 + id * REGISTER_STRIDE;
}
#define HOST1X_SYNC_MLOCK_OWNER(id) \
host1x_sync_mlock_owner_r(id)
static inline u32 host1x_sync_mlock_owner_chid_f(u32 v)
{
return (v & 0xf) << 8;
}
#define HOST1X_SYNC_MLOCK_OWNER_CHID_F(v) \
host1x_sync_mlock_owner_chid_f(v)
static inline u32 host1x_sync_mlock_owner_cpu_owns_v(u32 r)
{
return (r >> 1) & 0x1;
}
#define HOST1X_SYNC_MLOCK_OWNER_CPU_OWNS_V(r) \
host1x_sync_mlock_owner_cpu_owns_v(r)
static inline u32 host1x_sync_mlock_owner_ch_owns_v(u32 r)
{
return (r >> 0) & 0x1;
}
#define HOST1X_SYNC_MLOCK_OWNER_CH_OWNS_V(r) \
host1x_sync_mlock_owner_ch_owns_v(r)
static inline u32 host1x_sync_syncpt_int_thresh_r(unsigned int id)
{
return 0x500 + id * REGISTER_STRIDE;
}
#define HOST1X_SYNC_SYNCPT_INT_THRESH(id) \
host1x_sync_syncpt_int_thresh_r(id)
static inline u32 host1x_sync_syncpt_base_r(unsigned int id)
{
return 0x600 + id * REGISTER_STRIDE;
}
#define HOST1X_SYNC_SYNCPT_BASE(id) \
host1x_sync_syncpt_base_r(id)
static inline u32 host1x_sync_syncpt_cpu_incr_r(unsigned int id)
{
return 0x700 + id * REGISTER_STRIDE;
}
#define HOST1X_SYNC_SYNCPT_CPU_INCR(id) \
host1x_sync_syncpt_cpu_incr_r(id)
static inline u32 host1x_sync_cbread_r(unsigned int channel)
{
return 0x720 + channel * REGISTER_STRIDE;
}
#define HOST1X_SYNC_CBREAD(channel) \
host1x_sync_cbread_r(channel)
static inline u32 host1x_sync_cfpeek_ctrl_r(void)
{
return 0x74c;
}
#define HOST1X_SYNC_CFPEEK_CTRL \
host1x_sync_cfpeek_ctrl_r()
static inline u32 host1x_sync_cfpeek_ctrl_addr_f(u32 v)
{
return (v & 0x3ff) << 0;
}
#define HOST1X_SYNC_CFPEEK_CTRL_ADDR_F(v) \
host1x_sync_cfpeek_ctrl_addr_f(v)
static inline u32 host1x_sync_cfpeek_ctrl_channr_f(u32 v)
{
return (v & 0xf) << 16;
}
#define HOST1X_SYNC_CFPEEK_CTRL_CHANNR_F(v) \
host1x_sync_cfpeek_ctrl_channr_f(v)
static inline u32 host1x_sync_cfpeek_ctrl_ena_f(u32 v)
{
return (v & 0x1) << 31;
}
#define HOST1X_SYNC_CFPEEK_CTRL_ENA_F(v) \
host1x_sync_cfpeek_ctrl_ena_f(v)
static inline u32 host1x_sync_cfpeek_read_r(void)
{
return 0x750;
}
#define HOST1X_SYNC_CFPEEK_READ \
host1x_sync_cfpeek_read_r()
static inline u32 host1x_sync_cfpeek_ptrs_r(void)
{
return 0x754;
}
#define HOST1X_SYNC_CFPEEK_PTRS \
host1x_sync_cfpeek_ptrs_r()
static inline u32 host1x_sync_cfpeek_ptrs_cf_rd_ptr_v(u32 r)
{
return (r >> 0) & 0x3ff;
}
#define HOST1X_SYNC_CFPEEK_PTRS_CF_RD_PTR_V(r) \
host1x_sync_cfpeek_ptrs_cf_rd_ptr_v(r)
static inline u32 host1x_sync_cfpeek_ptrs_cf_wr_ptr_v(u32 r)
{
return (r >> 16) & 0x3ff;
}
#define HOST1X_SYNC_CFPEEK_PTRS_CF_WR_PTR_V(r) \
host1x_sync_cfpeek_ptrs_cf_wr_ptr_v(r)
static inline u32 host1x_sync_cbstat_r(unsigned int channel)
{
return 0x758 + channel * REGISTER_STRIDE;
}
#define HOST1X_SYNC_CBSTAT(channel) \
host1x_sync_cbstat_r(channel)
static inline u32 host1x_sync_cbstat_cboffset_v(u32 r)
{
return (r >> 0) & 0xffff;
}
#define HOST1X_SYNC_CBSTAT_CBOFFSET_V(r) \
host1x_sync_cbstat_cboffset_v(r)
static inline u32 host1x_sync_cbstat_cbclass_v(u32 r)
{
return (r >> 16) & 0x3ff;
}
#define HOST1X_SYNC_CBSTAT_CBCLASS_V(r) \
host1x_sync_cbstat_cbclass_v(r)
#endif
/*
* Copyright (c) 2013 NVIDIA Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* Function naming determines intended use:
*
* <x>_r(void) : Returns the offset for register <x>.
*
* <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
*
* <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
*
* <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
* and masked to place it at field <y> of register <x>. This value
* can be |'d with others to produce a full register value for
* register <x>.
*
* <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
* value can be ~'d and then &'d to clear the value of field <y> for
* register <x>.
*
* <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
* to place it at field <y> of register <x>. This value can be |'d
* with others to produce a full register value for <x>.
*
* <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
* <x> value 'r' after being shifted to place its LSB at bit 0.
* This value is suitable for direct comparison with other unshifted
* values appropriate for use in field <y> of register <x>.
*
* <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
* field <y> of register <x>. This value is suitable for direct
* comparison with unshifted values appropriate for use in field <y>
* of register <x>.
*/
#ifndef HOST1X_HW_HOST1X02_UCLASS_H
#define HOST1X_HW_HOST1X02_UCLASS_H
static inline u32 host1x_uclass_incr_syncpt_r(void)
{
return 0x0;
}
#define HOST1X_UCLASS_INCR_SYNCPT \
host1x_uclass_incr_syncpt_r()
static inline u32 host1x_uclass_incr_syncpt_cond_f(u32 v)
{
return (v & 0xff) << 8;
}
#define HOST1X_UCLASS_INCR_SYNCPT_COND_F(v) \
host1x_uclass_incr_syncpt_cond_f(v)
static inline u32 host1x_uclass_incr_syncpt_indx_f(u32 v)
{
return (v & 0xff) << 0;
}
#define HOST1X_UCLASS_INCR_SYNCPT_INDX_F(v) \
host1x_uclass_incr_syncpt_indx_f(v)
static inline u32 host1x_uclass_wait_syncpt_r(void)
{
return 0x8;
}
#define HOST1X_UCLASS_WAIT_SYNCPT \
host1x_uclass_wait_syncpt_r()
static inline u32 host1x_uclass_wait_syncpt_indx_f(u32 v)
{
return (v & 0xff) << 24;
}
#define HOST1X_UCLASS_WAIT_SYNCPT_INDX_F(v) \
host1x_uclass_wait_syncpt_indx_f(v)
static inline u32 host1x_uclass_wait_syncpt_thresh_f(u32 v)
{
return (v & 0xffffff) << 0;
}
#define HOST1X_UCLASS_WAIT_SYNCPT_THRESH_F(v) \
host1x_uclass_wait_syncpt_thresh_f(v)
static inline u32 host1x_uclass_wait_syncpt_base_r(void)
{
return 0x9;
}
#define HOST1X_UCLASS_WAIT_SYNCPT_BASE \
host1x_uclass_wait_syncpt_base_r()
static inline u32 host1x_uclass_wait_syncpt_base_indx_f(u32 v)
{
return (v & 0xff) << 24;
}
#define HOST1X_UCLASS_WAIT_SYNCPT_BASE_INDX_F(v) \
host1x_uclass_wait_syncpt_base_indx_f(v)
static inline u32 host1x_uclass_wait_syncpt_base_base_indx_f(u32 v)
{
return (v & 0xff) << 16;
}
#define HOST1X_UCLASS_WAIT_SYNCPT_BASE_BASE_INDX_F(v) \
host1x_uclass_wait_syncpt_base_base_indx_f(v)
static inline u32 host1x_uclass_wait_syncpt_base_offset_f(u32 v)
{
return (v & 0xffff) << 0;
}
#define HOST1X_UCLASS_WAIT_SYNCPT_BASE_OFFSET_F(v) \
host1x_uclass_wait_syncpt_base_offset_f(v)
static inline u32 host1x_uclass_load_syncpt_base_base_indx_f(u32 v)
{
return (v & 0xff) << 24;
}
#define HOST1X_UCLASS_LOAD_SYNCPT_BASE_BASE_INDX_F(v) \
host1x_uclass_load_syncpt_base_base_indx_f(v)
static inline u32 host1x_uclass_load_syncpt_base_value_f(u32 v)
{
return (v & 0xffffff) << 0;
}
#define HOST1X_UCLASS_LOAD_SYNCPT_BASE_VALUE_F(v) \
host1x_uclass_load_syncpt_base_value_f(v)
static inline u32 host1x_uclass_incr_syncpt_base_base_indx_f(u32 v)
{
return (v & 0xff) << 24;
}
#define HOST1X_UCLASS_INCR_SYNCPT_BASE_BASE_INDX_F(v) \
host1x_uclass_incr_syncpt_base_base_indx_f(v)
static inline u32 host1x_uclass_incr_syncpt_base_offset_f(u32 v)
{
return (v & 0xffffff) << 0;
}
#define HOST1X_UCLASS_INCR_SYNCPT_BASE_OFFSET_F(v) \
host1x_uclass_incr_syncpt_base_offset_f(v)
static inline u32 host1x_uclass_indoff_r(void)
{
return 0x2d;
}
#define HOST1X_UCLASS_INDOFF \
host1x_uclass_indoff_r()
static inline u32 host1x_uclass_indoff_indbe_f(u32 v)
{
return (v & 0xf) << 28;
}
#define HOST1X_UCLASS_INDOFF_INDBE_F(v) \
host1x_uclass_indoff_indbe_f(v)
static inline u32 host1x_uclass_indoff_autoinc_f(u32 v)
{
return (v & 0x1) << 27;
}
#define HOST1X_UCLASS_INDOFF_AUTOINC_F(v) \
host1x_uclass_indoff_autoinc_f(v)
static inline u32 host1x_uclass_indoff_indmodid_f(u32 v)
{
return (v & 0xff) << 18;
}
#define HOST1X_UCLASS_INDOFF_INDMODID_F(v) \
host1x_uclass_indoff_indmodid_f(v)
static inline u32 host1x_uclass_indoff_indroffset_f(u32 v)
{
return (v & 0xffff) << 2;
}
#define HOST1X_UCLASS_INDOFF_INDROFFSET_F(v) \
host1x_uclass_indoff_indroffset_f(v)
static inline u32 host1x_uclass_indoff_rwn_read_v(void)
{
return 1;
}
#define HOST1X_UCLASS_INDOFF_INDROFFSET_F(v) \
host1x_uclass_indoff_indroffset_f(v)
#endif
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include <linux/io.h> #include <linux/io.h>
#include <asm/mach/irq.h> #include <asm/mach/irq.h>
#include "intr.h" #include "../intr.h"
#include "dev.h" #include "../dev.h"
/* /*
* Sync point threshold interrupt service function * Sync point threshold interrupt service function
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include <linux/io.h> #include <linux/io.h>
#include "dev.h" #include "../dev.h"
#include "syncpt.h" #include "../syncpt.h"
/* /*
* Write the current syncpoint value back to hw. * Write the current syncpoint value back to hw.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#define __HOST1X_SYNCPT_H #define __HOST1X_SYNCPT_H
#include <linux/atomic.h> #include <linux/atomic.h>
#include <linux/host1x.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -30,6 +31,11 @@ struct host1x; ...@@ -30,6 +31,11 @@ struct host1x;
/* Reserved for replacing an expired wait with a NOP */ /* Reserved for replacing an expired wait with a NOP */
#define HOST1X_SYNCPT_RESERVED 0 #define HOST1X_SYNCPT_RESERVED 0
struct host1x_syncpt_base {
unsigned int id;
bool requested;
};
struct host1x_syncpt { struct host1x_syncpt {
int id; int id;
atomic_t min_val; atomic_t min_val;
...@@ -39,6 +45,7 @@ struct host1x_syncpt { ...@@ -39,6 +45,7 @@ struct host1x_syncpt {
bool client_managed; bool client_managed;
struct host1x *host; struct host1x *host;
struct device *dev; struct device *dev;
struct host1x_syncpt_base *base;
/* interrupt data */ /* interrupt data */
struct host1x_syncpt_intr intr; struct host1x_syncpt_intr intr;
...@@ -50,25 +57,6 @@ int host1x_syncpt_init(struct host1x *host); ...@@ -50,25 +57,6 @@ int host1x_syncpt_init(struct host1x *host);
/* Free sync point array */ /* Free sync point array */
void host1x_syncpt_deinit(struct host1x *host); void host1x_syncpt_deinit(struct host1x *host);
/*
* Read max. It indicates how many operations there are in queue, either in
* channel or in a software thread.
* */
static inline u32 host1x_syncpt_read_max(struct host1x_syncpt *sp)
{
smp_rmb();
return (u32)atomic_read(&sp->max_val);
}
/*
* Read min, which is a shadow of the current sync point value in hardware.
*/
static inline u32 host1x_syncpt_read_min(struct host1x_syncpt *sp)
{
smp_rmb();
return (u32)atomic_read(&sp->min_val);
}
/* Return number of sync point supported. */ /* Return number of sync point supported. */
int host1x_syncpt_nb_pts(struct host1x *host); int host1x_syncpt_nb_pts(struct host1x *host);
...@@ -112,9 +100,6 @@ static inline bool host1x_syncpt_idle(struct host1x_syncpt *sp) ...@@ -112,9 +100,6 @@ static inline bool host1x_syncpt_idle(struct host1x_syncpt *sp)
return (min == max); return (min == max);
} }
/* Return pointer to struct denoting sync point id. */
struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, u32 id);
/* Load current value from hardware to the shadow register. */ /* Load current value from hardware to the shadow register. */
u32 host1x_syncpt_load(struct host1x_syncpt *sp); u32 host1x_syncpt_load(struct host1x_syncpt *sp);
...@@ -130,16 +115,9 @@ void host1x_syncpt_restore(struct host1x *host); ...@@ -130,16 +115,9 @@ void host1x_syncpt_restore(struct host1x *host);
/* Read current wait base value into shadow register and return it. */ /* Read current wait base value into shadow register and return it. */
u32 host1x_syncpt_load_wait_base(struct host1x_syncpt *sp); u32 host1x_syncpt_load_wait_base(struct host1x_syncpt *sp);
/* Request incrementing a sync point. */
int host1x_syncpt_incr(struct host1x_syncpt *sp);
/* Indicate future operations by incrementing the sync point max. */ /* Indicate future operations by incrementing the sync point max. */
u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs); u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs);
/* Wait until sync point reaches a threshold value, or a timeout. */
int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh,
long timeout, u32 *value);
/* Check if sync point id is valid. */ /* Check if sync point id is valid. */
static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp) static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp)
{ {
...@@ -149,14 +127,4 @@ static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp) ...@@ -149,14 +127,4 @@ static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp)
/* Patch a wait by replacing it with a wait for syncpt 0 value 0 */ /* Patch a wait by replacing it with a wait for syncpt 0 value 0 */
int host1x_syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr); int host1x_syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr);
/* Return id of the sync point */
u32 host1x_syncpt_id(struct host1x_syncpt *sp);
/* Allocate a sync point for a device. */
struct host1x_syncpt *host1x_syncpt_request(struct device *dev,
bool client_managed);
/* Free a sync point. */
void host1x_syncpt_free(struct host1x_syncpt *sp);
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment