From 521aae88f1f463a82bb4d2bda3350bfa8cae0836 Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Tue, 19 May 2015 02:10:46 +0300 Subject: [PATCH] HACK: staging: Add downstream NVIDIA video driver Signed-off-by: Dmitry Osipenko --- drivers/clk/tegra/clk-tegra20.c | 22 + drivers/of/platform.c | 43 + drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 2 + drivers/staging/tegra/Kconfig | 12 + drivers/staging/tegra/Makefile | 7 + drivers/staging/tegra/clk.c | 8 + drivers/staging/tegra/csi.c | 85 + drivers/staging/tegra/include/linux/nvhost.h | 255 ++ .../tegra/include/linux/nvhost_ioctl.h | 213 + drivers/staging/tegra/include/linux/nvmap.h | 144 + .../tegra/include/linux/tegra_overlay.h | 79 + drivers/staging/tegra/include/mach/clk.h | 47 + drivers/staging/tegra/include/mach/csi.h | 40 + drivers/staging/tegra/include/mach/fuse.h | 21 + .../staging/tegra/include/mach/hdmi-audio.h | 47 + drivers/staging/tegra/include/mach/iovmm.h | 352 ++ drivers/staging/tegra/include/mach/kfuse.h | 20 + .../tegra/include/mach/latency_allowance.h | 109 + drivers/staging/tegra/include/mach/mc.h | 101 + .../staging/tegra/include/mach/powergate.h | 32 + .../tegra/include/media/tegra_camera.h | 60 + .../tegra/include/trace/events/nvhost.h | 568 +++ .../tegra/include/trace/events/nvmap.h | 303 ++ drivers/staging/tegra/include/video/nvhdcp.h | 91 + .../tegra/include/video/tegra_dc_ext.h | 331 ++ drivers/staging/tegra/include/video/tegrafb.h | 32 + drivers/staging/tegra/pageattr.c | 66 + drivers/staging/tegra/powergate.c | 218 + drivers/staging/tegra/video/Kconfig | 201 + drivers/staging/tegra/video/Makefile | 10 + drivers/staging/tegra/video/dc/Makefile | 14 + drivers/staging/tegra/video/dc/bandwidth.c | 284 ++ drivers/staging/tegra/video/dc/clock.c | 144 + drivers/staging/tegra/video/dc/csc.c | 69 + drivers/staging/tegra/video/dc/dc.c | 2417 ++++++++++++ drivers/staging/tegra/video/dc/dc.h | 618 +++ drivers/staging/tegra/video/dc/dc_config.c | 247 ++ drivers/staging/tegra/video/dc/dc_config.h | 162 + drivers/staging/tegra/video/dc/dc_priv.h | 407 ++ drivers/staging/tegra/video/dc/dc_reg.h | 564 +++ drivers/staging/tegra/video/dc/dc_sysfs.c | 373 ++ drivers/staging/tegra/video/dc/dsi.c | 3509 +++++++++++++++++ drivers/staging/tegra/video/dc/dsi.h | 375 ++ drivers/staging/tegra/video/dc/dsi_regs.h | 351 ++ drivers/staging/tegra/video/dc/edid.c | 605 +++ drivers/staging/tegra/video/dc/edid.h | 86 + drivers/staging/tegra/video/dc/ext/Makefile | 8 + drivers/staging/tegra/video/dc/ext/control.c | 276 ++ drivers/staging/tegra/video/dc/ext/cursor.c | 203 + drivers/staging/tegra/video/dc/ext/dev.c | 1140 ++++++ drivers/staging/tegra/video/dc/ext/events.c | 197 + .../tegra/video/dc/ext/tegra_dc_ext_priv.h | 152 + drivers/staging/tegra/video/dc/ext/util.c | 78 + drivers/staging/tegra/video/dc/fb.h | 64 + drivers/staging/tegra/video/dc/hdmi.c | 2519 ++++++++++++ drivers/staging/tegra/video/dc/hdmi.h | 222 ++ drivers/staging/tegra/video/dc/hdmi_reg.h | 480 +++ drivers/staging/tegra/video/dc/lut.c | 130 + drivers/staging/tegra/video/dc/mode.c | 343 ++ drivers/staging/tegra/video/dc/nvhdcp.c | 1259 ++++++ drivers/staging/tegra/video/dc/nvhdcp.h | 46 + drivers/staging/tegra/video/dc/nvsd.c | 914 +++++ drivers/staging/tegra/video/dc/nvsd.h | 25 + drivers/staging/tegra/video/dc/overlay.c | 893 +++++ drivers/staging/tegra/video/dc/overlay.h | 43 + drivers/staging/tegra/video/dc/rgb.c | 158 + drivers/staging/tegra/video/dc/tegra_dc_ext.h | 78 + drivers/staging/tegra/video/dc/tegra_fb.h | 27 + drivers/staging/tegra/video/dc/window.c | 469 +++ drivers/staging/tegra/video/fb.c | 776 ++++ drivers/staging/tegra/video/host/Makefile | 31 + drivers/staging/tegra/video/host/bus.c | 715 ++++ drivers/staging/tegra/video/host/bus.h | 38 + drivers/staging/tegra/video/host/bus_client.c | 669 ++++ drivers/staging/tegra/video/host/bus_client.h | 42 + .../staging/tegra/video/host/chip_support.c | 56 + .../staging/tegra/video/host/chip_support.h | 181 + drivers/staging/tegra/video/host/debug.c | 234 ++ drivers/staging/tegra/video/host/debug.h | 50 + drivers/staging/tegra/video/host/dev.c | 31 + drivers/staging/tegra/video/host/dev.h | 25 + .../staging/tegra/video/host/gr2d/Makefile | 8 + drivers/staging/tegra/video/host/gr2d/gr2d.c | 80 + .../staging/tegra/video/host/gr3d/Makefile | 11 + drivers/staging/tegra/video/host/gr3d/gr3d.c | 278 ++ drivers/staging/tegra/video/host/gr3d/gr3d.h | 57 + .../staging/tegra/video/host/gr3d/gr3d_t20.c | 399 ++ .../staging/tegra/video/host/gr3d/gr3d_t20.h | 33 + .../staging/tegra/video/host/gr3d/gr3d_t30.c | 437 ++ .../staging/tegra/video/host/gr3d/gr3d_t30.h | 33 + .../staging/tegra/video/host/gr3d/scale3d.c | 941 +++++ .../staging/tegra/video/host/gr3d/scale3d.h | 47 + .../staging/tegra/video/host/host1x/Makefile | 8 + .../staging/tegra/video/host/host1x/host1x.c | 580 +++ .../staging/tegra/video/host/host1x/host1x.h | 90 + .../video/host/host1x/host1x01_hardware.h | 170 + .../tegra/video/host/host1x/host1x_cdma.c | 517 +++ .../tegra/video/host/host1x/host1x_cdma.h | 39 + .../tegra/video/host/host1x/host1x_channel.c | 681 ++++ .../tegra/video/host/host1x/host1x_debug.c | 405 ++ .../tegra/video/host/host1x/host1x_hwctx.h | 66 + .../tegra/video/host/host1x/host1x_intr.c | 278 ++ .../tegra/video/host/host1x/host1x_syncpt.c | 180 + .../tegra/video/host/host1x/host1x_syncpt.h | 62 + .../video/host/host1x/hw_host1x01_channel.h | 182 + .../video/host/host1x/hw_host1x01_sync.h | 398 ++ .../video/host/host1x/hw_host1x01_uclass.h | 474 +++ drivers/staging/tegra/video/host/isp/Makefile | 8 + drivers/staging/tegra/video/host/isp/isp.c | 86 + drivers/staging/tegra/video/host/mpe/Makefile | 8 + drivers/staging/tegra/video/host/mpe/mpe.c | 696 ++++ drivers/staging/tegra/video/host/mpe/mpe.h | 32 + drivers/staging/tegra/video/host/nvhost_acm.c | 671 ++++ drivers/staging/tegra/video/host/nvhost_acm.h | 58 + .../staging/tegra/video/host/nvhost_cdma.c | 559 +++ .../staging/tegra/video/host/nvhost_cdma.h | 117 + .../staging/tegra/video/host/nvhost_channel.c | 188 + .../staging/tegra/video/host/nvhost_channel.h | 77 + .../staging/tegra/video/host/nvhost_hwctx.h | 66 + .../staging/tegra/video/host/nvhost_intr.c | 406 ++ .../staging/tegra/video/host/nvhost_intr.h | 115 + drivers/staging/tegra/video/host/nvhost_job.c | 358 ++ drivers/staging/tegra/video/host/nvhost_job.h | 148 + .../staging/tegra/video/host/nvhost_memmgr.c | 35 + .../staging/tegra/video/host/nvhost_memmgr.h | 38 + .../staging/tegra/video/host/nvhost_syncpt.c | 510 +++ .../staging/tegra/video/host/nvhost_syncpt.h | 151 + drivers/staging/tegra/video/host/nvmap.c | 100 + drivers/staging/tegra/video/host/nvmap.h | 27 + drivers/staging/tegra/video/host/t20/Makefile | 8 + drivers/staging/tegra/video/host/t20/t20.c | 256 ++ drivers/staging/tegra/video/host/t20/t20.h | 29 + drivers/staging/tegra/video/host/t30/Makefile | 8 + drivers/staging/tegra/video/host/t30/t30.c | 283 ++ drivers/staging/tegra/video/host/t30/t30.h | 29 + drivers/staging/tegra/video/host/vi/Makefile | 8 + drivers/staging/tegra/video/host/vi/vi.c | 86 + drivers/staging/tegra/video/nvmap/Makefile | 10 + drivers/staging/tegra/video/nvmap/nvmap.c | 619 +++ drivers/staging/tegra/video/nvmap/nvmap.h | 321 ++ .../staging/tegra/video/nvmap/nvmap_common.h | 29 + drivers/staging/tegra/video/nvmap/nvmap_dev.c | 1499 +++++++ .../staging/tegra/video/nvmap/nvmap_handle.c | 1069 +++++ .../staging/tegra/video/nvmap/nvmap_heap.c | 1129 ++++++ .../staging/tegra/video/nvmap/nvmap_heap.h | 68 + .../staging/tegra/video/nvmap/nvmap_ioctl.c | 800 ++++ .../staging/tegra/video/nvmap/nvmap_ioctl.h | 162 + .../staging/tegra/video/nvmap/nvmap_iommu.c | 96 + drivers/staging/tegra/video/nvmap/nvmap_mru.c | 187 + drivers/staging/tegra/video/nvmap/nvmap_mru.h | 84 + 151 files changed, 44006 insertions(+) create mode 100644 drivers/staging/tegra/Kconfig create mode 100644 drivers/staging/tegra/Makefile create mode 100644 drivers/staging/tegra/clk.c create mode 100644 drivers/staging/tegra/csi.c create mode 100644 drivers/staging/tegra/include/linux/nvhost.h create mode 100644 drivers/staging/tegra/include/linux/nvhost_ioctl.h create mode 100644 drivers/staging/tegra/include/linux/nvmap.h create mode 100644 drivers/staging/tegra/include/linux/tegra_overlay.h create mode 100644 drivers/staging/tegra/include/mach/clk.h create mode 100644 drivers/staging/tegra/include/mach/csi.h create mode 100644 drivers/staging/tegra/include/mach/fuse.h create mode 100644 drivers/staging/tegra/include/mach/hdmi-audio.h create mode 100644 drivers/staging/tegra/include/mach/iovmm.h create mode 100644 drivers/staging/tegra/include/mach/kfuse.h create mode 100644 drivers/staging/tegra/include/mach/latency_allowance.h create mode 100644 drivers/staging/tegra/include/mach/mc.h create mode 100644 drivers/staging/tegra/include/mach/powergate.h create mode 100644 drivers/staging/tegra/include/media/tegra_camera.h create mode 100644 drivers/staging/tegra/include/trace/events/nvhost.h create mode 100644 drivers/staging/tegra/include/trace/events/nvmap.h create mode 100644 drivers/staging/tegra/include/video/nvhdcp.h create mode 100644 drivers/staging/tegra/include/video/tegra_dc_ext.h create mode 100644 drivers/staging/tegra/include/video/tegrafb.h create mode 100644 drivers/staging/tegra/pageattr.c create mode 100644 drivers/staging/tegra/powergate.c create mode 100644 drivers/staging/tegra/video/Kconfig create mode 100644 drivers/staging/tegra/video/Makefile create mode 100644 drivers/staging/tegra/video/dc/Makefile create mode 100644 drivers/staging/tegra/video/dc/bandwidth.c create mode 100644 drivers/staging/tegra/video/dc/clock.c create mode 100644 drivers/staging/tegra/video/dc/csc.c create mode 100644 drivers/staging/tegra/video/dc/dc.c create mode 100644 drivers/staging/tegra/video/dc/dc.h create mode 100644 drivers/staging/tegra/video/dc/dc_config.c create mode 100644 drivers/staging/tegra/video/dc/dc_config.h create mode 100644 drivers/staging/tegra/video/dc/dc_priv.h create mode 100644 drivers/staging/tegra/video/dc/dc_reg.h create mode 100644 drivers/staging/tegra/video/dc/dc_sysfs.c create mode 100644 drivers/staging/tegra/video/dc/dsi.c create mode 100644 drivers/staging/tegra/video/dc/dsi.h create mode 100644 drivers/staging/tegra/video/dc/dsi_regs.h create mode 100644 drivers/staging/tegra/video/dc/edid.c create mode 100644 drivers/staging/tegra/video/dc/edid.h create mode 100644 drivers/staging/tegra/video/dc/ext/Makefile create mode 100644 drivers/staging/tegra/video/dc/ext/control.c create mode 100644 drivers/staging/tegra/video/dc/ext/cursor.c create mode 100644 drivers/staging/tegra/video/dc/ext/dev.c create mode 100644 drivers/staging/tegra/video/dc/ext/events.c create mode 100644 drivers/staging/tegra/video/dc/ext/tegra_dc_ext_priv.h create mode 100644 drivers/staging/tegra/video/dc/ext/util.c create mode 100644 drivers/staging/tegra/video/dc/fb.h create mode 100644 drivers/staging/tegra/video/dc/hdmi.c create mode 100644 drivers/staging/tegra/video/dc/hdmi.h create mode 100644 drivers/staging/tegra/video/dc/hdmi_reg.h create mode 100644 drivers/staging/tegra/video/dc/lut.c create mode 100644 drivers/staging/tegra/video/dc/mode.c create mode 100644 drivers/staging/tegra/video/dc/nvhdcp.c create mode 100644 drivers/staging/tegra/video/dc/nvhdcp.h create mode 100644 drivers/staging/tegra/video/dc/nvsd.c create mode 100644 drivers/staging/tegra/video/dc/nvsd.h create mode 100644 drivers/staging/tegra/video/dc/overlay.c create mode 100644 drivers/staging/tegra/video/dc/overlay.h create mode 100644 drivers/staging/tegra/video/dc/rgb.c create mode 100644 drivers/staging/tegra/video/dc/tegra_dc_ext.h create mode 100644 drivers/staging/tegra/video/dc/tegra_fb.h create mode 100644 drivers/staging/tegra/video/dc/window.c create mode 100644 drivers/staging/tegra/video/fb.c create mode 100644 drivers/staging/tegra/video/host/Makefile create mode 100644 drivers/staging/tegra/video/host/bus.c create mode 100644 drivers/staging/tegra/video/host/bus.h create mode 100644 drivers/staging/tegra/video/host/bus_client.c create mode 100644 drivers/staging/tegra/video/host/bus_client.h create mode 100644 drivers/staging/tegra/video/host/chip_support.c create mode 100644 drivers/staging/tegra/video/host/chip_support.h create mode 100644 drivers/staging/tegra/video/host/debug.c create mode 100644 drivers/staging/tegra/video/host/debug.h create mode 100644 drivers/staging/tegra/video/host/dev.c create mode 100644 drivers/staging/tegra/video/host/dev.h create mode 100644 drivers/staging/tegra/video/host/gr2d/Makefile create mode 100644 drivers/staging/tegra/video/host/gr2d/gr2d.c create mode 100644 drivers/staging/tegra/video/host/gr3d/Makefile create mode 100644 drivers/staging/tegra/video/host/gr3d/gr3d.c create mode 100644 drivers/staging/tegra/video/host/gr3d/gr3d.h create mode 100644 drivers/staging/tegra/video/host/gr3d/gr3d_t20.c create mode 100644 drivers/staging/tegra/video/host/gr3d/gr3d_t20.h create mode 100644 drivers/staging/tegra/video/host/gr3d/gr3d_t30.c create mode 100644 drivers/staging/tegra/video/host/gr3d/gr3d_t30.h create mode 100644 drivers/staging/tegra/video/host/gr3d/scale3d.c create mode 100644 drivers/staging/tegra/video/host/gr3d/scale3d.h create mode 100644 drivers/staging/tegra/video/host/host1x/Makefile create mode 100644 drivers/staging/tegra/video/host/host1x/host1x.c create mode 100644 drivers/staging/tegra/video/host/host1x/host1x.h create mode 100644 drivers/staging/tegra/video/host/host1x/host1x01_hardware.h create mode 100644 drivers/staging/tegra/video/host/host1x/host1x_cdma.c create mode 100644 drivers/staging/tegra/video/host/host1x/host1x_cdma.h create mode 100644 drivers/staging/tegra/video/host/host1x/host1x_channel.c create mode 100644 drivers/staging/tegra/video/host/host1x/host1x_debug.c create mode 100644 drivers/staging/tegra/video/host/host1x/host1x_hwctx.h create mode 100644 drivers/staging/tegra/video/host/host1x/host1x_intr.c create mode 100644 drivers/staging/tegra/video/host/host1x/host1x_syncpt.c create mode 100644 drivers/staging/tegra/video/host/host1x/host1x_syncpt.h create mode 100644 drivers/staging/tegra/video/host/host1x/hw_host1x01_channel.h create mode 100644 drivers/staging/tegra/video/host/host1x/hw_host1x01_sync.h create mode 100644 drivers/staging/tegra/video/host/host1x/hw_host1x01_uclass.h create mode 100644 drivers/staging/tegra/video/host/isp/Makefile create mode 100644 drivers/staging/tegra/video/host/isp/isp.c create mode 100644 drivers/staging/tegra/video/host/mpe/Makefile create mode 100644 drivers/staging/tegra/video/host/mpe/mpe.c create mode 100644 drivers/staging/tegra/video/host/mpe/mpe.h create mode 100644 drivers/staging/tegra/video/host/nvhost_acm.c create mode 100644 drivers/staging/tegra/video/host/nvhost_acm.h create mode 100644 drivers/staging/tegra/video/host/nvhost_cdma.c create mode 100644 drivers/staging/tegra/video/host/nvhost_cdma.h create mode 100644 drivers/staging/tegra/video/host/nvhost_channel.c create mode 100644 drivers/staging/tegra/video/host/nvhost_channel.h create mode 100644 drivers/staging/tegra/video/host/nvhost_hwctx.h create mode 100644 drivers/staging/tegra/video/host/nvhost_intr.c create mode 100644 drivers/staging/tegra/video/host/nvhost_intr.h create mode 100644 drivers/staging/tegra/video/host/nvhost_job.c create mode 100644 drivers/staging/tegra/video/host/nvhost_job.h create mode 100644 drivers/staging/tegra/video/host/nvhost_memmgr.c create mode 100644 drivers/staging/tegra/video/host/nvhost_memmgr.h create mode 100644 drivers/staging/tegra/video/host/nvhost_syncpt.c create mode 100644 drivers/staging/tegra/video/host/nvhost_syncpt.h create mode 100644 drivers/staging/tegra/video/host/nvmap.c create mode 100644 drivers/staging/tegra/video/host/nvmap.h create mode 100644 drivers/staging/tegra/video/host/t20/Makefile create mode 100644 drivers/staging/tegra/video/host/t20/t20.c create mode 100644 drivers/staging/tegra/video/host/t20/t20.h create mode 100644 drivers/staging/tegra/video/host/t30/Makefile create mode 100644 drivers/staging/tegra/video/host/t30/t30.c create mode 100644 drivers/staging/tegra/video/host/t30/t30.h create mode 100644 drivers/staging/tegra/video/host/vi/Makefile create mode 100644 drivers/staging/tegra/video/host/vi/vi.c create mode 100644 drivers/staging/tegra/video/nvmap/Makefile create mode 100644 drivers/staging/tegra/video/nvmap/nvmap.c create mode 100644 drivers/staging/tegra/video/nvmap/nvmap.h create mode 100644 drivers/staging/tegra/video/nvmap/nvmap_common.h create mode 100644 drivers/staging/tegra/video/nvmap/nvmap_dev.c create mode 100644 drivers/staging/tegra/video/nvmap/nvmap_handle.c create mode 100644 drivers/staging/tegra/video/nvmap/nvmap_heap.c create mode 100644 drivers/staging/tegra/video/nvmap/nvmap_heap.h create mode 100644 drivers/staging/tegra/video/nvmap/nvmap_ioctl.c create mode 100644 drivers/staging/tegra/video/nvmap/nvmap_ioctl.h create mode 100644 drivers/staging/tegra/video/nvmap/nvmap_iommu.c create mode 100644 drivers/staging/tegra/video/nvmap/nvmap_mru.c create mode 100644 drivers/staging/tegra/video/nvmap/nvmap_mru.h diff --git a/drivers/clk/tegra/clk-tegra20.c b/drivers/clk/tegra/clk-tegra20.c index 837e5cbd60e9..f76874a00e60 100644 --- a/drivers/clk/tegra/clk-tegra20.c +++ b/drivers/clk/tegra/clk-tegra20.c @@ -205,14 +205,36 @@ static struct tegra_clk_pll_freq_table pll_a_freq_table[] = { }; static struct tegra_clk_pll_freq_table pll_d_freq_table[] = { + { 12000000, 5000000, 10, 24, 1, 4 }, + { 12000000, 10000000, 10, 12, 1, 4 }, + { 12000000, 161500000, 323, 24, 1, 4 }, + { 12000000, 162000000, 162, 12, 1, 4 }, + { 12000000, 216000000, 216, 12, 1, 4 }, { 13000000, 216000000, 216, 13, 1, 4 }, { 19200000, 216000000, 135, 12, 1, 3 }, { 26000000, 216000000, 216, 26, 1, 4 }, + + { 12000000, 252000000, 252, 12, 1, 4 }, + { 13000000, 252000000, 252, 13, 1, 4 }, + { 19200000, 252000000, 210, 16, 1, 3 }, + { 26000000, 252000000, 252, 26, 1, 4 }, + + { 12000000, 297000000, 297, 12, 1, 4 }, + { 13000000, 297000000, 297, 13, 1, 4 }, + { 19200000, 297000000, 248, 16, 1, 4 }, + { 26000000, 297000000, 297, 26, 1, 4 }, + + { 12000000, 504000000, 504, 12, 1, 8 }, + { 13000000, 504000000, 504, 13, 1, 8 }, + { 19200000, 504000000, 420, 16, 1, 8 }, + { 26000000, 504000000, 504, 26, 1, 8 }, + { 12000000, 594000000, 594, 12, 1, 8 }, { 13000000, 594000000, 594, 13, 1, 8 }, { 19200000, 594000000, 495, 16, 1, 8 }, { 26000000, 594000000, 594, 26, 1, 8 }, + { 12000000, 1000000000, 1000, 12, 1, 12 }, { 13000000, 1000000000, 1000, 13, 1, 12 }, { 19200000, 1000000000, 625, 12, 1, 8 }, diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 16e8daffac06..5692509f70ec 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -23,6 +23,8 @@ #include #include +#include <../drivers/staging/tegra/include/linux/nvhost.h> + const struct of_device_id of_default_bus_match_table[] = { { .compatible = "simple-bus", }, { .compatible = "simple-mfd", }, @@ -333,6 +335,42 @@ static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *l return NULL; } +/** + * Assume that all child devices belongs to nvhost + */ +static int of_nvhost_bus_create(struct device_node *node, + const struct of_dev_auxdata *lookup) +{ + const struct of_dev_auxdata *auxdata; + struct device_node *child; + const char *bus_id = NULL; + void *platform_data = NULL; + int rc; + + if (!of_device_is_available(node)) + return -ENODEV; + + auxdata = of_dev_lookup(lookup, node); + if (auxdata) { + bus_id = auxdata->name; + platform_data = auxdata->platform_data; + } + + pr_debug(" nvhost create host: %s\n", node->name); + rc = of_nvhost_device_create(node, bus_id, platform_data); + if (rc) + return rc; + + for_each_child_of_node(node, child) { + pr_debug(" nvhost create child: %s\n", child->full_name); + rc = of_nvhost_bus_create(child, lookup); + if (rc) + of_node_put(child); + } + + return rc; +} + /** * of_platform_bus_create() - Create a device for a node and its children. * @bus: device node of the bus to instantiate @@ -378,6 +416,11 @@ static int of_platform_bus_create(struct device_node *bus, return 0; } + if (of_device_is_compatible(bus, "nvhost-bus")) { + of_nvhost_bus_create(bus, tegra20_auxdata_lookup); + return 0; + } + dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent); if (!dev || !of_match_node(matches, bus)) return 0; diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 46e38e702dd8..b329c99680fe 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -24,6 +24,8 @@ menuconfig STAGING if STAGING +source "drivers/staging/tegra/Kconfig" + source "drivers/staging/a500/Kconfig" source "drivers/staging/slicoss/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 4656175ffce2..c985cd625324 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -1,5 +1,7 @@ # Makefile for staging directory +obj-$(CONFIG_TEGRA_DOWNSTREAM) += tegra/ + obj-$(CONFIG_A500) += a500/ obj-y += media/ diff --git a/drivers/staging/tegra/Kconfig b/drivers/staging/tegra/Kconfig new file mode 100644 index 000000000000..23e7d5aa3f02 --- /dev/null +++ b/drivers/staging/tegra/Kconfig @@ -0,0 +1,12 @@ +config TEGRA_DOWNSTREAM + bool "Downstream NVIDIA Tegra drivers" + depends on ARCH_TEGRA && !CONFIG_TEGRA20_MC + default n + help + Say Y to build downstream NVIDIA Tegra 2/3 drivers. + +if TEGRA_DOWNSTREAM + +source "drivers/staging/tegra/video/Kconfig" + +endif # TEGRA_DOWNSTREAM diff --git a/drivers/staging/tegra/Makefile b/drivers/staging/tegra/Makefile new file mode 100644 index 000000000000..26b035281347 --- /dev/null +++ b/drivers/staging/tegra/Makefile @@ -0,0 +1,7 @@ +EXTRA_CFLAGS += -Idrivers/staging/tegra/include + +obj-$(CONFIG_TEGRA_DOWNSTREAM) += video/ +obj-$(CONFIG_TEGRA_DOWNSTREAM) += csi.o +obj-$(CONFIG_TEGRA_DOWNSTREAM) += clk.o +obj-$(CONFIG_TEGRA_DOWNSTREAM) += pageattr.o +obj-$(CONFIG_TEGRA_DOWNSTREAM) += powergate.o diff --git a/drivers/staging/tegra/clk.c b/drivers/staging/tegra/clk.c new file mode 100644 index 000000000000..b7745340f38d --- /dev/null +++ b/drivers/staging/tegra/clk.c @@ -0,0 +1,8 @@ +#include +#include + +int tegra_is_clk_enabled(struct clk *c) +{ + return __clk_get_enable_count(c); +} +EXPORT_SYMBOL(tegra_is_clk_enabled); diff --git a/drivers/staging/tegra/csi.c b/drivers/staging/tegra/csi.c new file mode 100644 index 000000000000..6e18c2f97163 --- /dev/null +++ b/drivers/staging/tegra/csi.c @@ -0,0 +1,85 @@ +/* + * arch/arm/mach-tegra/csi.c + * + * Copyright (C) 2010-2011 NVIDIA Corporation. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that 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. + * + */ + +#include +#include +#include +#include +#include + +#include + +#include <../arch/arm/mach-tegra/iomap.h> + +#define TEGRA_VI_BASE 0x54080000 + +static struct clk *vi_clk; +static struct clk *csi_clk; + +int tegra_vi_csi_writel(u32 val, u32 offset) +{ + if (vi_clk == NULL) { + vi_clk = clk_get_sys("tegra_camera", "vi"); + if (IS_ERR_OR_NULL(vi_clk)) { + pr_err("vi: can't get vi clock\n"); + return -EINVAL; + } + } + clk_prepare_enable(vi_clk); + + if (csi_clk == NULL) { + csi_clk = clk_get_sys("tegra_camera", "csi"); + if (IS_ERR_OR_NULL(csi_clk)) { + pr_err("csi: can't get csi clock\n"); + return -EINVAL; + } + } + clk_prepare_enable(csi_clk); + + writel(val, IO_ADDRESS(TEGRA_VI_BASE) + offset * 4); + + clk_disable_unprepare(csi_clk); + clk_disable_unprepare(vi_clk); + return 0; +} + +int tegra_vi_csi_readl(u32 offset, u32 *val) +{ + if (vi_clk == NULL) { + vi_clk = clk_get_sys("tegra_camera", "vi"); + if (IS_ERR_OR_NULL(vi_clk)) { + pr_err("vi: can't get vi clock\n"); + return -EINVAL; + } + } + clk_prepare_enable(vi_clk); + + if (csi_clk == NULL) { + csi_clk = clk_get_sys("tegra_camera", "csi"); + if (IS_ERR_OR_NULL(csi_clk)) { + pr_err("csi: can't get csi clock\n"); + return -EINVAL; + } + } + clk_prepare_enable(csi_clk); + + *val = readl(IO_ADDRESS(TEGRA_VI_BASE) + offset * 4); + + clk_disable_unprepare(csi_clk); + clk_disable_unprepare(vi_clk); + + return 0; +} diff --git a/drivers/staging/tegra/include/linux/nvhost.h b/drivers/staging/tegra/include/linux/nvhost.h new file mode 100644 index 000000000000..0e4c3843f3b3 --- /dev/null +++ b/drivers/staging/tegra/include/linux/nvhost.h @@ -0,0 +1,255 @@ +/* + * include/linux/nvhost.h + * + * Tegra graphics host driver + * + * Copyright (c) 2009-2012, NVIDIA Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __LINUX_NVHOST_H +#define __LINUX_NVHOST_H + +#include +#include +#include + +struct nvhost_master; + +struct nvhost_device_power_attr; + +#define NVHOST_MODULE_MAX_CLOCKS 3 +#define NVHOST_MODULE_MAX_POWERGATE_IDS 2 +#define NVHOST_MODULE_NO_POWERGATE_IDS .powergate_ids = {-1, -1} +#define NVHOST_DEFAULT_CLOCKGATE_DELAY .clockgate_delay = 25 +#define NVHOST_NAME_SIZE 24 +#define NVSYNCPT_INVALID (-1) + +/* FIXME: + * Sync point ids are now split into 2 files. + * 1 if this one and other is in + * drivers/video/tegra/host/host1x/host1x_syncpt.h + * So if someone decides to add new sync point in future + * please check both the header files + */ +#define NVSYNCPT_DISP0_A (8) +#define NVSYNCPT_DISP1_A (9) +#define NVSYNCPT_AVP_0 (10) +#define NVSYNCPT_DISP0_B (20) +#define NVSYNCPT_DISP1_B (21) +#define NVSYNCPT_DISP0_C (24) +#define NVSYNCPT_DISP1_C (25) +#define NVSYNCPT_VBLANK0 (26) +#define NVSYNCPT_VBLANK1 (27) +#define NVSYNCPT_DSI (31) + +enum nvhost_power_sysfs_attributes { + NVHOST_POWER_SYSFS_ATTRIB_CLOCKGATE_DELAY = 0, + NVHOST_POWER_SYSFS_ATTRIB_POWERGATE_DELAY, + NVHOST_POWER_SYSFS_ATTRIB_REFCOUNT, + NVHOST_POWER_SYSFS_ATTRIB_MAX +}; + +struct nvhost_device_id { + char name[NVHOST_NAME_SIZE]; + unsigned long version; +}; + +struct nvhost_clock { + char *name; + long default_rate; +}; + +enum nvhost_device_powerstate_t { + NVHOST_POWER_STATE_DEINIT, + NVHOST_POWER_STATE_RUNNING, + NVHOST_POWER_STATE_CLOCKGATED, + NVHOST_POWER_STATE_POWERGATED +}; + +struct nvhost_device { + const char *name; /* device name */ + int version; /* ip version number of device */ + struct device dev; /* Linux device struct */ + int id; /* Separates clients of same hw */ + int index; /* Hardware channel number */ + u32 num_resources; /* Number of resources following */ + struct resource *resource; /* Resources (IOMEM in particular) */ + struct resource *reg_mem; + void __iomem *aperture; /* Iomem mapped to kernel */ + + u32 syncpts; /* Bitfield of sync points used */ + u32 waitbases; /* Bit field of wait bases */ + u32 modulemutexes; /* Bit field of module mutexes */ + u32 moduleid; /* Module id for user space API */ + + u32 class; /* Device class */ + bool exclusive; /* True if only one user at a time */ + bool keepalive; /* Do not power gate when opened */ + bool waitbasesync; /* Force sync of wait bases */ + bool powerup_reset; /* Do a reset after power un-gating */ + bool serialize; /* Serialize submits in the channel */ + + int powergate_ids[NVHOST_MODULE_MAX_POWERGATE_IDS]; + bool can_powergate; /* True if module can be power gated */ + int clockgate_delay;/* Delay before clock gated */ + int powergate_delay;/* Delay before power gated */ + struct nvhost_clock clocks[NVHOST_MODULE_MAX_CLOCKS];/* Clock names */ + + struct delayed_work powerstate_down;/* Power state management */ + int num_clks; /* Number of clocks opened for dev */ + struct clk *clk[NVHOST_MODULE_MAX_CLOCKS]; + struct mutex lock; /* Power management lock */ + int powerstate; /* Current power state */ + int refcount; /* Number of tasks active */ + wait_queue_head_t idle_wq; /* Work queue for idle */ + struct list_head client_list; /* List of clients and rate requests */ + + struct nvhost_channel *channel; /* Channel assigned for the module */ + struct kobject *power_kobj; /* kobject to hold power sysfs entries */ + struct nvhost_device_power_attr *power_attrib; /* sysfs attributes */ + + bool is_dynamic; + + struct reset_control *rst; +}; + +struct nvhost_device_power_attr { + struct nvhost_device *ndev; + struct kobj_attribute power_attr[NVHOST_POWER_SYSFS_ATTRIB_MAX]; +}; + +/* Register devices to nvhost bus */ +extern int nvhost_add_devices(struct nvhost_device **, int num); + +/* Register device to nvhost bus */ +extern int nvhost_device_register(struct nvhost_device *); + +/* Deregister device from nvhost bus */ +extern void nvhost_device_unregister(struct nvhost_device *); + +struct nvhost_driver { + int (*probe)(struct nvhost_device *, struct nvhost_device_id *); + int (*remove)(struct nvhost_device *); + void (*shutdown)(struct nvhost_device *); + int (*suspend)(struct nvhost_device *, pm_message_t state); + int (*resume)(struct nvhost_device *); + struct device_driver driver; + + struct nvhost_device_id *id_table; + + /* Finalize power on. Can be used for context restore. */ + void (*finalize_poweron)(struct nvhost_device *dev); + + /* Device is busy. */ + void (*busy)(struct nvhost_device *); + + /* Device is idle. */ + void (*idle)(struct nvhost_device *); + + /* Device is going to be suspended */ + void (*suspend_ndev)(struct nvhost_device *); + + /* Device is initialized */ + void (*init)(struct nvhost_device *dev); + + /* Device is de-initialized. */ + void (*deinit)(struct nvhost_device *dev); + + /* Preparing for power off. Used for context save. */ + int (*prepare_poweroff)(struct nvhost_device *dev); + + /* Allocates a context handler for the device */ + struct nvhost_hwctx_handler *(*alloc_hwctx_handler)(u32 syncpt, + u32 waitbase, struct nvhost_channel *ch); + + /* Clock gating callbacks */ + int (*prepare_clockoff)(struct nvhost_device *dev); + void (*finalize_clockon)(struct nvhost_device *dev); +}; + +extern int nvhost_driver_register(struct nvhost_driver *); +extern void nvhost_driver_unregister(struct nvhost_driver *); +extern struct resource *nvhost_get_resource(struct nvhost_device *, + unsigned int, unsigned int); +extern int nvhost_get_irq(struct nvhost_device *, unsigned int); +extern struct resource *nvhost_get_resource_byname(struct nvhost_device *, + unsigned int, const char *); +extern int nvhost_get_irq_byname(struct nvhost_device *, const char *); + +#define to_nvhost_device(x) container_of((x), struct nvhost_device, dev) +#define to_nvhost_driver(drv) (container_of((drv), struct nvhost_driver, \ + driver)) + +#define nvhost_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev) +#define nvhost_set_drvdata(_dev, data) dev_set_drvdata(&(_dev)->dev, (data)) + +int nvhost_bus_add_host(struct nvhost_master *host); +int nvhost_bus_init(void); + +static inline struct nvhost_device *nvhost_get_parent(struct nvhost_device *_dev) +{ + return _dev->dev.parent ? to_nvhost_device(_dev->dev.parent) : NULL; +} + +/* public host1x power management APIs */ +bool nvhost_module_powered_ext(struct nvhost_device *dev); +void nvhost_module_busy_ext(struct nvhost_device *dev); +void nvhost_module_idle_ext(struct nvhost_device *dev); + +/* public host1x sync-point management APIs */ +u32 nvhost_syncpt_incr_max_ext(struct nvhost_device *dev, u32 id, u32 incrs); +void nvhost_syncpt_cpu_incr_ext(struct nvhost_device *dev, u32 id); +u32 nvhost_syncpt_read_ext(struct nvhost_device *dev, u32 id); +int nvhost_syncpt_wait_timeout_ext(struct nvhost_device *dev, u32 id, u32 thresh, + u32 timeout, u32 *value); + +void nvhost_scale3d_set_throughput_hint(int hint); + +int of_nvhost_device_create(struct device_node *np, const char *bus_id, + void *aux_dev); + +extern struct nvhost_device tegra_host1x01_t20_device; +extern struct nvhost_device tegra_display01_t20_device; +extern struct nvhost_device tegra_gr3d01_t20_device; +extern struct nvhost_device tegra_gr2d01_t20_device; +extern struct nvhost_device tegra_isp01_t20_device; +extern struct nvhost_device tegra_vi01_t20_device; +extern struct nvhost_device tegra_mpe01_t20_device; +extern struct nvhost_device tegra_dsi01_t20_device; + +#define NVHOST_T20_OF_DEV_AUXDATA \ + OF_DEV_AUXDATA("nvidia,tegra20-host1x", 0x50000000, "host1x", \ + &tegra_host1x01_t20_device), \ + OF_DEV_AUXDATA("nvidia,tegra20-display", 0, "display", \ + &tegra_display01_t20_device), \ + OF_DEV_AUXDATA("nvidia,tegra20-gr3d", 0x54180000, "gr3d", \ + &tegra_gr3d01_t20_device), \ + OF_DEV_AUXDATA("nvidia,tegra20-gr2d", 0x54140000, "gr2d", \ + &tegra_gr2d01_t20_device), \ + OF_DEV_AUXDATA("nvidia,tegra20-isp", 0x54100000, "isp", \ + &tegra_isp01_t20_device), \ + OF_DEV_AUXDATA("nvidia,tegra20-vi", 0x54080000, "vi", \ + &tegra_vi01_t20_device), \ + OF_DEV_AUXDATA("nvidia,tegra20-mpe", 0x54040000, "mpe", \ + &tegra_mpe01_t20_device), \ + OF_DEV_AUXDATA("nvidia,tegra20-dsi", 0x54300000, "dsi", \ + &tegra_dsi01_t20_device), \ + OF_DEV_AUXDATA("nvidia,tegra20-dc", 0x54200000, "tegradc.0", NULL), \ + OF_DEV_AUXDATA("nvidia,tegra20-dc", 0x54240000, "tegradc.1", NULL) \ + +extern struct of_dev_auxdata tegra20_auxdata_lookup[]; +#endif diff --git a/drivers/staging/tegra/include/linux/nvhost_ioctl.h b/drivers/staging/tegra/include/linux/nvhost_ioctl.h new file mode 100644 index 000000000000..3f6eabf522f1 --- /dev/null +++ b/drivers/staging/tegra/include/linux/nvhost_ioctl.h @@ -0,0 +1,213 @@ +/* + * include/linux/nvhost_ioctl.h + * + * Tegra graphics host driver + * + * Copyright (c) 2009-2012, NVIDIA Corporation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __LINUX_NVHOST_IOCTL_H +#define __LINUX_NVHOST_IOCTL_H + +#include +#include + +#if !defined(__KERNEL__) +#define __user +#endif + +#define NVHOST_INVALID_SYNCPOINT 0xFFFFFFFF +#define NVHOST_NO_TIMEOUT (-1) +#define NVHOST_NO_CONTEXT 0x0 +#define NVHOST_IOCTL_MAGIC 'H' +#define NVHOST_PRIORITY_LOW 50 +#define NVHOST_PRIORITY_MEDIUM 100 +#define NVHOST_PRIORITY_HIGH 150 + +/* version 0 header (used with write() submit interface) */ +struct nvhost_submit_hdr { + __u32 syncpt_id; + __u32 syncpt_incrs; + __u32 num_cmdbufs; + __u32 num_relocs; +}; + +#define NVHOST_SUBMIT_VERSION_V0 0x0 +#define NVHOST_SUBMIT_VERSION_V1 0x1 +#define NVHOST_SUBMIT_VERSION_V2 0x2 +#define NVHOST_SUBMIT_VERSION_MAX_SUPPORTED NVHOST_SUBMIT_VERSION_V2 + +/* version 1 header (used with ioctl() submit interface) */ +struct nvhost_submit_hdr_ext { + __u32 syncpt_id; /* version 0 fields */ + __u32 syncpt_incrs; + __u32 num_cmdbufs; + __u32 num_relocs; + __u32 submit_version; /* version 1 fields */ + __u32 num_waitchks; + __u32 waitchk_mask; + __u32 pad[5]; /* future expansion */ +}; + +struct nvhost_cmdbuf { + __u32 mem; + __u32 offset; + __u32 words; +}; + +struct nvhost_reloc { + __u32 cmdbuf_mem; + __u32 cmdbuf_offset; + __u32 target; + __u32 target_offset; +}; + +struct nvhost_reloc_shift { + __u32 shift; +}; + +struct nvhost_waitchk { + __u32 mem; + __u32 offset; + __u32 syncpt_id; + __u32 thresh; +}; + +struct nvhost_get_param_args { + __u32 value; +}; + +struct nvhost_set_nvmap_fd_args { + __u32 fd; +}; + +struct nvhost_read_3d_reg_args { + __u32 offset; + __u32 value; +}; + +struct nvhost_clk_rate_args { + __u64 rate; +}; + +struct nvhost_set_timeout_args { + __u32 timeout; +}; + +struct nvhost_set_priority_args { + __u32 priority; +}; + +#define NVHOST_IOCTL_CHANNEL_FLUSH \ + _IOR(NVHOST_IOCTL_MAGIC, 1, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_GET_SYNCPOINTS \ + _IOR(NVHOST_IOCTL_MAGIC, 2, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_GET_WAITBASES \ + _IOR(NVHOST_IOCTL_MAGIC, 3, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_GET_MODMUTEXES \ + _IOR(NVHOST_IOCTL_MAGIC, 4, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_SET_NVMAP_FD \ + _IOW(NVHOST_IOCTL_MAGIC, 5, struct nvhost_set_nvmap_fd_args) +#define NVHOST_IOCTL_CHANNEL_NULL_KICKOFF \ + _IOR(NVHOST_IOCTL_MAGIC, 6, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_SUBMIT_EXT \ + _IOW(NVHOST_IOCTL_MAGIC, 7, struct nvhost_submit_hdr_ext) +#define NVHOST_IOCTL_CHANNEL_READ_3D_REG \ + _IOWR(NVHOST_IOCTL_MAGIC, 8, struct nvhost_read_3d_reg_args) +#define NVHOST_IOCTL_CHANNEL_GET_CLK_RATE \ + _IOR(NVHOST_IOCTL_MAGIC, 9, struct nvhost_clk_rate_args) +#define NVHOST_IOCTL_CHANNEL_SET_CLK_RATE \ + _IOW(NVHOST_IOCTL_MAGIC, 10, struct nvhost_clk_rate_args) +#define NVHOST_IOCTL_CHANNEL_SET_TIMEOUT \ + _IOW(NVHOST_IOCTL_MAGIC, 11, struct nvhost_set_timeout_args) +#define NVHOST_IOCTL_CHANNEL_GET_TIMEDOUT \ + _IOR(NVHOST_IOCTL_MAGIC, 12, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_SET_PRIORITY \ + _IOW(NVHOST_IOCTL_MAGIC, 13, struct nvhost_set_priority_args) +#define NVHOST_IOCTL_CHANNEL_LAST \ + _IOC_NR(NVHOST_IOCTL_CHANNEL_SET_PRIORITY) +#define NVHOST_IOCTL_CHANNEL_MAX_ARG_SIZE sizeof(struct nvhost_submit_hdr_ext) + +struct nvhost_ctrl_syncpt_read_args { + __u32 id; + __u32 value; +}; + +struct nvhost_ctrl_syncpt_incr_args { + __u32 id; +}; + +struct nvhost_ctrl_syncpt_wait_args { + __u32 id; + __u32 thresh; + __s32 timeout; +}; + +struct nvhost_ctrl_syncpt_waitex_args { + __u32 id; + __u32 thresh; + __s32 timeout; + __u32 value; +}; + +struct nvhost_ctrl_module_mutex_args { + __u32 id; + __u32 lock; +}; + +enum nvhost_module_id { + NVHOST_MODULE_NONE = -1, + NVHOST_MODULE_DISPLAY_A = 0, + NVHOST_MODULE_DISPLAY_B, + NVHOST_MODULE_VI, + NVHOST_MODULE_ISP, + NVHOST_MODULE_MPE, +}; + +struct nvhost_ctrl_module_regrdwr_args { + __u32 id; + __u32 num_offsets; + __u32 block_size; + __u32 *offsets; + __u32 *values; + __u32 write; +}; + +#define NVHOST_IOCTL_CTRL_SYNCPT_READ \ + _IOWR(NVHOST_IOCTL_MAGIC, 1, struct nvhost_ctrl_syncpt_read_args) +#define NVHOST_IOCTL_CTRL_SYNCPT_INCR \ + _IOW(NVHOST_IOCTL_MAGIC, 2, struct nvhost_ctrl_syncpt_incr_args) +#define NVHOST_IOCTL_CTRL_SYNCPT_WAIT \ + _IOW(NVHOST_IOCTL_MAGIC, 3, struct nvhost_ctrl_syncpt_wait_args) + +#define NVHOST_IOCTL_CTRL_MODULE_MUTEX \ + _IOWR(NVHOST_IOCTL_MAGIC, 4, struct nvhost_ctrl_module_mutex_args) +#define NVHOST_IOCTL_CTRL_MODULE_REGRDWR \ + _IOWR(NVHOST_IOCTL_MAGIC, 5, struct nvhost_ctrl_module_regrdwr_args) + +#define NVHOST_IOCTL_CTRL_SYNCPT_WAITEX \ + _IOWR(NVHOST_IOCTL_MAGIC, 6, struct nvhost_ctrl_syncpt_waitex_args) + +#define NVHOST_IOCTL_CTRL_GET_VERSION \ + _IOR(NVHOST_IOCTL_MAGIC, 7, struct nvhost_get_param_args) + +#define NVHOST_IOCTL_CTRL_LAST \ + _IOC_NR(NVHOST_IOCTL_CTRL_GET_VERSION) +#define NVHOST_IOCTL_CTRL_MAX_ARG_SIZE \ + sizeof(struct nvhost_ctrl_module_regrdwr_args) + +#endif diff --git a/drivers/staging/tegra/include/linux/nvmap.h b/drivers/staging/tegra/include/linux/nvmap.h new file mode 100644 index 000000000000..7d8b248787bb --- /dev/null +++ b/drivers/staging/tegra/include/linux/nvmap.h @@ -0,0 +1,144 @@ +/* + * include/linux/nvmap.h + * + * structure declarations for nvmem and nvmap user-space ioctls + * + * Copyright (c) 2009-2012, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include + +#if !defined(__KERNEL__) +#define __user +#endif + +#ifndef _LINUX_NVMAP_H +#define _LINUX_NVMAP_H + +#define NVMAP_HEAP_SYSMEM (1ul<<31) +#define NVMAP_HEAP_IOVMM (1ul<<30) + +/* common carveout heaps */ +#define NVMAP_HEAP_CARVEOUT_IRAM (1ul<<29) +#define NVMAP_HEAP_CARVEOUT_VPR (1ul<<28) +#define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0) + +#define NVMAP_HEAP_CARVEOUT_MASK (NVMAP_HEAP_IOVMM - 1) + +/* allocation flags */ +#define NVMAP_HANDLE_UNCACHEABLE (0x0ul << 0) +#define NVMAP_HANDLE_WRITE_COMBINE (0x1ul << 0) +#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0) +#define NVMAP_HANDLE_CACHEABLE (0x3ul << 0) +#define NVMAP_HANDLE_CACHE_FLAG (0x3ul << 0) + +#define NVMAP_HANDLE_SECURE (0x1ul << 2) +#define NVMAP_HANDLE_ZEROED_PAGES (0x1ul << 3) + +#if defined(__KERNEL__) + +#if defined(CONFIG_TEGRA_NVMAP) +struct nvmap_handle; +struct nvmap_client; +struct nvmap_device; + +#define nvmap_ref_to_handle(_ref) (*(struct nvmap_handle **)(_ref)) +/* Convert User space handle to Kernel. */ +#define nvmap_convert_handle_u2k(h) (h) + +/* handle_ref objects are client-local references to an nvmap_handle; + * they are distinct objects so that handles can be unpinned and + * unreferenced the correct number of times when a client abnormally + * terminates */ +struct nvmap_handle_ref { + struct nvmap_handle *handle; + struct rb_node node; + atomic_t dupes; /* number of times to free on file close */ + atomic_t pin; /* number of times to unpin on free */ +}; + +#elif defined(CONFIG_ION_TEGRA) +/* For Ion Mem Manager support through nvmap_* API's. */ +#include "../../../../../drivers/gpu/ion/ion_priv.h" +#define nvmap_client ion_client +#define nvmap_device ion_device +#define nvmap_handle ion_handle +#define nvmap_handle_ref ion_handle +#define nvmap_ref_to_handle(_ref) (struct ion_handle *)_ref +/* Convert User space handle to Kernel. */ +#define nvmap_convert_handle_u2k(h) ({ \ + if ((u32)h >= TASK_SIZE) { \ + pr_err("Invalid user space handle."); \ + BUG(); \ + } \ + (*((u32 *)h)); }) + +#endif /* CONFIG_ION_TEGRA */ + +#define nvmap_id_to_handle(_id) ((struct nvmap_handle *)(_id)) + +struct nvmap_client *nvmap_create_client(struct nvmap_device *dev, + const char *name); + +struct nvmap_handle_ref *nvmap_alloc(struct nvmap_client *client, size_t size, + size_t align, unsigned int flags, + unsigned int heap_mask); + +void nvmap_free(struct nvmap_client *client, struct nvmap_handle_ref *r); + +void *nvmap_mmap(struct nvmap_handle_ref *r); + +void nvmap_munmap(struct nvmap_handle_ref *r, void *addr); + +struct nvmap_client *nvmap_client_get_file(int fd); + +struct nvmap_client *nvmap_client_get(struct nvmap_client *client); + +void nvmap_client_put(struct nvmap_client *c); + +phys_addr_t nvmap_pin(struct nvmap_client *c, struct nvmap_handle_ref *r); + +phys_addr_t nvmap_handle_address(struct nvmap_client *c, unsigned long id); + +void nvmap_unpin(struct nvmap_client *client, struct nvmap_handle_ref *r); + +void nvmap_unpin_handles(struct nvmap_client *client, + struct nvmap_handle **h, int nr); + +struct nvmap_handle_ref *nvmap_duplicate_handle_id(struct nvmap_client *client, + unsigned long id); + +struct nvmap_platform_carveout { + const char *name; + unsigned int usage_mask; + phys_addr_t base; + size_t size; + size_t buddy_size; +}; + +struct nvmap_platform_data { + struct nvmap_platform_carveout *carveouts; + unsigned int nr_carveouts; +}; + +extern struct nvmap_device *nvmap_dev; + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_NVMAP_H */ diff --git a/drivers/staging/tegra/include/linux/tegra_overlay.h b/drivers/staging/tegra/include/linux/tegra_overlay.h new file mode 100644 index 000000000000..2a6025afdad7 --- /dev/null +++ b/drivers/staging/tegra/include/linux/tegra_overlay.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010 NVIDIA Corporation + * Author: Dan Willemsen + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that 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. + * + */ + +#ifndef __LINUX_TEGRA_OVERLAY_H +#define __LINUX_TEGRA_OVERLAY_H + +#include +#include +#include