dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Terje Bergstrom <tbergstrom-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org,
	airlied-cv59FeDIM0c@public.gmane.org,
	dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Terje Bergstrom <tbergstrom-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: [PATCHv4 8/8] gpu: host1x: Register DRM dummy device
Date: Fri, 21 Dec 2012 13:39:24 +0200	[thread overview]
Message-ID: <1356089964-5265-9-git-send-email-tbergstrom@nvidia.com> (raw)
In-Reply-To: <1356089964-5265-1-git-send-email-tbergstrom-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Register a dummy device for tegradrm, and provide a getter to
access the device.

Signed-off-by: Terje Bergstrom <tbergstrom-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/gpu/drm/tegra/dc.c   |    5 ++++-
 drivers/gpu/drm/tegra/drm.c  |   11 +--------
 drivers/gpu/drm/tegra/gr2d.c |    4 +++-
 drivers/gpu/drm/tegra/hdmi.c |    5 ++++-
 drivers/gpu/host1x/Makefile  |    3 ++-
 drivers/gpu/host1x/dev.c     |    9 ++++++++
 drivers/gpu/host1x/dev.h     |    2 ++
 drivers/gpu/host1x/drm.c     |   51 ++++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/host1x/drm.h     |   25 +++++++++++++++++++++
 include/linux/host1x.h       |    2 ++
 10 files changed, 103 insertions(+), 14 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm.c
 create mode 100644 drivers/gpu/host1x/drm.h

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 24bcd06..d01be50 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/host1x.h>
 
 #include <mach/clk.h>
 
@@ -740,7 +741,9 @@ static int tegra_dc_probe(struct platform_device *pdev)
 	struct resource *regs;
 	struct tegra_dc *dc;
 	int err;
-	struct tegradrm *tegradrm = platform_get_drvdata(pdev);
+	struct platform_device *drm_device =
+		host1x_drm_device(to_platform_device(pdev->dev.parent));
+	struct tegradrm *tegradrm = platform_get_drvdata(drm_device);
 
 	dc = devm_kzalloc(&pdev->dev, sizeof(*dc), GFP_KERNEL);
 	if (!dc)
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 637b621..d64935d 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -56,7 +56,6 @@ static int tegra_drm_add_client(struct device *dev, void *data)
 			client->np = of_node_get(dev->of_node);
 
 			list_add_tail(&client->list, &tegradrm->drm_clients);
-			dev_set_drvdata(dev, tegradrm);
 		}
 	}
 
@@ -258,16 +257,10 @@ static struct platform_driver tegra_drm_platform_driver = {
 static int __init tegra_drm_init(void)
 {
 	int err;
-	struct platform_device *drm_device;
-
-	drm_device = platform_device_register_simple("tegradrm", -1, NULL, 0);
-	if (!drm_device)
-		return -ENOMEM;
-	dma_set_coherent_mask(&drm_device->dev, DMA_BIT_MASK(32));
 
 	err = platform_driver_register(&tegra_drm_platform_driver);
 	if (err < 0)
-		goto unregister_tegra_dev;
+		return err;
 
 	err = platform_driver_register(&tegra_dc_driver);
 	if (err < 0)
@@ -288,8 +281,6 @@ unregister_dc:
 	platform_driver_unregister(&tegra_dc_driver);
 unregister_tegra_drv:
 	platform_driver_unregister(&tegra_drm_platform_driver);
-unregister_tegra_dev:
-	platform_device_unregister(drm_device);
 	return err;
 }
 module_init(tegra_drm_init);
diff --git a/drivers/gpu/drm/tegra/gr2d.c b/drivers/gpu/drm/tegra/gr2d.c
index 8865099..a936902 100644
--- a/drivers/gpu/drm/tegra/gr2d.c
+++ b/drivers/gpu/drm/tegra/gr2d.c
@@ -247,7 +247,9 @@ static int __devinit gr2d_probe(struct platform_device *dev)
 {
 	int err;
 	struct gr2d *gr2d = NULL;
-	struct tegradrm *tegradrm = platform_get_drvdata(dev);
+	struct platform_device *drm_device =
+		host1x_drm_device(to_platform_device(dev->dev.parent));
+	struct tegradrm *tegradrm = platform_get_drvdata(drm_device);
 
 	gr2d = devm_kzalloc(&dev->dev, sizeof(*gr2d), GFP_KERNEL);
 	if (!gr2d)
diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
index fce3e66..a90a76f 100644
--- a/drivers/gpu/drm/tegra/hdmi.c
+++ b/drivers/gpu/drm/tegra/hdmi.c
@@ -14,6 +14,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
+#include <linux/host1x.h>
 
 #include <mach/clk.h>
 
@@ -1214,7 +1215,9 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
 	struct tegra_hdmi *hdmi;
 	struct resource *regs;
 	int err;
-	struct tegradrm *tegradrm = platform_get_drvdata(pdev);
+	struct platform_device *drm_device =
+		host1x_drm_device(to_platform_device(pdev->dev.parent));
+	struct tegradrm *tegradrm = platform_get_drvdata(drm_device);
 
 	hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
 	if (!hdmi)
diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index 049c07a..f8749fb 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -10,7 +10,8 @@ host1x-y = \
 	job.o \
 	debug.o \
 	memmgr.o \
-	hw/host1x01.o
+	hw/host1x01.o \
+	drm.o
 
 host1x-$(CONFIG_TEGRA_HOST1X_CMA) += cma.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index 8d710ef..07e8813 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -25,6 +25,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include "dev.h"
+#include "drm.h"
 #include "intr.h"
 #include "channel.h"
 #include "debug.h"
@@ -145,6 +146,12 @@ static int host1x_probe(struct platform_device *dev)
 
 	/* set common host1x device data */
 	platform_set_drvdata(dev, host);
+
+	/* Alloc DRM device */
+	err = host1x_register_drm_device(host);
+	if (err)
+		goto fail;
+
 	host->regs = devm_request_and_ioremap(&dev->dev, regs);
 	if (!host->regs) {
 		dev_err(&dev->dev, "failed to remap host registers\n");
@@ -203,6 +210,7 @@ static int host1x_probe(struct platform_device *dev)
 
 fail:
 	host1x_syncpt_free(host->nop_sp);
+	host1x_unregister_drm_device(host);
 	kfree(host);
 	return err;
 }
@@ -212,6 +220,7 @@ static int __exit host1x_remove(struct platform_device *dev)
 	struct host1x *host = platform_get_drvdata(dev);
 	host1x_intr_deinit(&host->intr);
 	host1x_syncpt_deinit(host);
+	host1x_unregister_drm_device(host);
 	clk_disable_unprepare(host->clk);
 	return 0;
 }
diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h
index aa5182e..05f8544 100644
--- a/drivers/gpu/host1x/dev.h
+++ b/drivers/gpu/host1x/dev.h
@@ -143,6 +143,8 @@ struct host1x {
 	int allocated_channels;
 
 	struct dentry *debugfs;
+
+	struct platform_device *drm_device;
 };
 
 static inline
diff --git a/drivers/gpu/host1x/drm.c b/drivers/gpu/host1x/drm.c
new file mode 100644
index 0000000..eaaaeed
--- /dev/null
+++ b/drivers/gpu/host1x/drm.c
@@ -0,0 +1,51 @@
+/*
+ * Tegra host1x driver DRM dummy device
+ *
+ * Copyright (c) 2012, 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 <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/module.h>
+#include "drm.h"
+#include "dev.h"
+
+int host1x_register_drm_device(struct host1x *host1x)
+{
+	struct platform_device *drm_device;
+
+	drm_device = platform_device_register_simple("tegradrm", -1, NULL, 0);
+	if (!drm_device)
+		return -ENOMEM;
+	dma_set_coherent_mask(&drm_device->dev, DMA_BIT_MASK(32));
+
+	host1x->drm_device = drm_device;
+	return 0;
+}
+EXPORT_SYMBOL(host1x_register_drm_device);
+
+void host1x_unregister_drm_device(struct host1x *host1x)
+{
+	if (host1x->drm_device)
+		platform_device_unregister(host1x->drm_device);
+}
+EXPORT_SYMBOL(host1x_unregister_drm_device);
+
+struct platform_device *host1x_drm_device(struct platform_device *pdev)
+{
+	struct host1x *host = platform_get_drvdata(pdev);
+	return host->drm_device;
+}
+EXPORT_SYMBOL(host1x_drm_device);
diff --git a/drivers/gpu/host1x/drm.h b/drivers/gpu/host1x/drm.h
new file mode 100644
index 0000000..84a827e
--- /dev/null
+++ b/drivers/gpu/host1x/drm.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2012, 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_DRM_H
+#define HOST1X_DRM_H
+
+struct host1x;
+
+int host1x_register_drm_device(struct host1x *host1x);
+void host1x_unregister_drm_device(struct host1x *host1x);
+
+#endif
diff --git a/include/linux/host1x.h b/include/linux/host1x.h
index a58c798..0906c19f 100644
--- a/include/linux/host1x.h
+++ b/include/linux/host1x.h
@@ -212,4 +212,6 @@ struct host1x_syncpt *host1x_syncpt_alloc(struct platform_device *pdev,
 		int client_managed);
 void host1x_syncpt_free(struct host1x_syncpt *sp);
 
+struct platform_device *host1x_drm_device(struct platform_device *pdev);
+
 #endif
-- 
1.7.9.5

  parent reply	other threads:[~2012-12-21 11:39 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21 11:39 [PATCHv4 0/8] Support for Tegra 2D hardware Terje Bergstrom
2012-12-21 11:39 ` [PATCHv4 1/8] gpu: host1x: Add host1x driver Terje Bergstrom
2012-12-21 11:39 ` [PATCHv4 2/8] gpu: host1x: Add syncpoint wait and interrupts Terje Bergstrom
2012-12-21 11:39 ` [PATCHv4 3/8] gpu: host1x: Add channel support Terje Bergstrom
     [not found]   ` <1356089964-5265-4-git-send-email-tbergstrom-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-12-22  4:17     ` Steven Rostedt
     [not found]       ` <1356149848.5896.124.camel-f9ZlEuEWxVcJvu8Pb33WZ0EMvNT87kid@public.gmane.org>
2013-01-02  9:31         ` Terje Bergström
2013-01-02  7:40   ` Mark Zhang
2013-01-02  9:31     ` Terje Bergström
     [not found]       ` <50E3FE8C.8000309-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-02  9:31         ` Mark Zhang
     [not found]           ` <50E3FE57.5070702-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-02  9:43             ` Terje Bergström
2012-12-21 11:39 ` [PATCHv4 4/8] gpu: host1x: Add debug support Terje Bergstrom
     [not found] ` <1356089964-5265-1-git-send-email-tbergstrom-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-12-21 11:39   ` [PATCHv4 5/8] drm: tegra: Remove redundant host1x Terje Bergstrom
     [not found]     ` <1356089964-5265-6-git-send-email-tbergstrom-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-12-21 14:36       ` Thierry Reding
2012-12-22  6:50         ` Terje Bergström
     [not found]           ` <50D55820.7030302-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-12-25  5:25             ` Stephen Warren
2012-12-28 21:21               ` Thierry Reding
2012-12-31  6:43                 ` Terje Bergström
     [not found]         ` <20121221143614.GA16167-RM9K5IK7kjIyiCvfTdI0JKcOhU4Rzj621B7CTYaBSLdn68oJJulU0Q@public.gmane.org>
2013-01-03 17:58           ` Terje Bergström
2012-12-21 11:39   ` [PATCHv4 6/8] ARM: tegra: Add board data and 2D clocks Terje Bergstrom
2012-12-21 11:39   ` Terje Bergstrom [this message]
     [not found]     ` <1356089964-5265-9-git-send-email-tbergstrom-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-12-21 13:53       ` [PATCHv4 8/8] gpu: host1x: Register DRM dummy device Lucas Stach
2012-12-21 14:09         ` Thierry Reding
2012-12-21 13:50   ` [PATCHv4 0/8] Support for Tegra 2D hardware Lucas Stach
2012-12-21 13:57     ` Terje Bergström
     [not found]       ` <50D46AE4.8020308-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-12-21 13:59         ` Lucas Stach
2013-01-03  6:14     ` Terje Bergström
2012-12-26  9:42   ` Mark Zhang
2013-01-02  9:25     ` Terje Bergström
     [not found]       ` <50E3FD17.80402-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-03  2:36         ` Mark Zhang
2012-12-21 11:39 ` [PATCHv4 7/8] drm: tegra: Add gr2d device Terje Bergstrom
2012-12-28  9:14 ` [PATCHv4 0/8] Support for Tegra 2D hardware Mark Zhang
     [not found]   ` <50DD6311.9000002-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-02  9:42     ` Terje Bergström
     [not found]       ` <50E40106.4020406-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-03  3:31         ` Mark Zhang
     [not found]           ` <50E4FBAF.30700-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-03  5:50             ` Terje Bergström
     [not found]               ` <50E51C08.1020603-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-03  5:55                 ` Mark Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1356089964-5265-9-git-send-email-tbergstrom@nvidia.com \
    --to=tbergstrom-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
    --cc=airlied-cv59FeDIM0c@public.gmane.org \
    --cc=dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).