devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sricharan R <r.sricharan@ti.com>
To: r.sricharan@ti.com, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
	dmaengine@vger.kernel.org
Cc: nm@ti.com, linux@arm.linux.org.uk, tony@atomide.com,
	rnayak@ti.com, nsekhar@ti.com, vinod.koul@intel.com,
	santosh.shilimkar@ti.com, dan.j.williams@intel.com
Subject: [RFC PATCH 2/9] drivers: dma: of-dma: Add support for dma-request line routers
Date: Fri, 7 Mar 2014 17:46:09 +0530	[thread overview]
Message-ID: <1394194576-23741-3-git-send-email-r.sricharan@ti.com> (raw)
In-Reply-To: <1394194576-23741-1-git-send-email-r.sricharan@ti.com>

In some socs dma requests lines from the peripherals to the
dma controller can be connected either directly or through
a crossbar router. The crossbar in turn maps the peripheral
request line to a free dma-controller request line. In such
cases the crossbar associated with the particular request lines
has to configured.

This add two APIS, one to register the crossbar router and other
to retrieve the router associated with a dma request line. The
peripheral's dma-specs mentions the dma-controller, request-line and
also the IP to which it is connected to via DT.

The dma-controller will have to check if a request line is routed
and then use that router's map/unmap function to configure the
request line.

Signed-off-by: Sricharan R <r.sricharan@ti.com>
---
 drivers/dma/of-dma.c   |   82 ++++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/of_dma.h |   22 +++++++++++++
 2 files changed, 102 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
index e8fe9dc..86129ef 100644
--- a/drivers/dma/of-dma.c
+++ b/drivers/dma/of-dma.c
@@ -19,7 +19,29 @@
 #include <linux/of_dma.h>
 
 static LIST_HEAD(of_dma_list);
+static LIST_HEAD(of_dma_router_list);
 static DEFINE_MUTEX(of_dma_lock);
+static DEFINE_MUTEX(of_dma_router_lock);
+
+/**
+ * of_dma_get_router_data - Get a DMA router in DT DMA routers list
+ * @phandle:	phandle to the dma router
+ *
+ * Finds a DMA router using matching phandle and returns the router
+ * specific data. Should be called from dma-controller xlate callback.
+ */
+void *of_dma_get_router_data(phandle router)
+{
+	struct of_dma_router *ofrouter;
+
+	list_for_each_entry(ofrouter, &of_dma_router_list, of_dma_routers) {
+		if (ofrouter->of_node->phandle == router)
+			return ofrouter->of_router_data;
+	}
+
+	return NULL;
+}
+EXPORT_SYMBOL(of_dma_get_router_data);
 
 /**
  * of_dma_find_controller - Get a DMA controller in DT DMA helpers list
@@ -45,6 +67,39 @@ static struct of_dma *of_dma_find_controller(struct of_phandle_args *dma_spec)
 }
 
 /**
+ * of_dma_router_register - Register a DMA router to DT DMA helpers
+ * @np:			device node of DMA controller
+ * @data		pointer to controller specific data to be used by
+ *			dma-controller
+ *
+ * Returns 0 on success or appropriate errno value on error.
+ *
+ * Allocated memory should be freed with appropriate of_dma_router_free()
+ * call.
+ */
+int of_dma_router_register(struct device_node *np, void *data)
+{
+	struct of_dma_router *ofrouter;
+
+	if (!np || !data)
+		return -EINVAL;
+
+	ofrouter = kzalloc(sizeof(*ofrouter), GFP_KERNEL);
+	if (!ofrouter)
+		return -ENOMEM;
+
+	ofrouter->of_node = np;
+	ofrouter->of_router_data = data;
+
+	mutex_lock(&of_dma_router_lock);
+	list_add_tail(&ofrouter->of_dma_routers, &of_dma_router_list);
+	mutex_unlock(&of_dma_router_lock);
+
+	return 0;
+}
+EXPORT_SYMBOL(of_dma_router_register);
+
+/**
  * of_dma_controller_register - Register a DMA controller to DT DMA helpers
  * @np:			device node of DMA controller
  * @of_dma_xlate:	translation function which converts a phandle
@@ -87,10 +142,10 @@ int of_dma_controller_register(struct device_node *np,
 EXPORT_SYMBOL_GPL(of_dma_controller_register);
 
 /**
- * of_dma_controller_free - Remove a DMA controller from DT DMA helpers list
+ * of_dma_router_free - Remove a DMA router from DT DMA routers list
  * @np:		device node of DMA controller
  *
- * Memory allocated by of_dma_controller_register() is freed here.
+ * Memory allocated by of_dma_router_register() is freed here.
  */
 void of_dma_controller_free(struct device_node *np)
 {
@@ -110,6 +165,29 @@ void of_dma_controller_free(struct device_node *np)
 EXPORT_SYMBOL_GPL(of_dma_controller_free);
 
 /**
+ * of_dma_controller_free - Remove a DMA controller from DT DMA helpers list
+ * @np:		device node of DMA controller
+ *
+ * Memory allocated by of_dma_router_register() is freed here.
+ */
+void of_dma_router_free(struct device_node *np)
+{
+	struct of_dma_router *ofrouter;
+
+	mutex_lock(&of_dma_router_lock);
+
+	list_for_each_entry(ofrouter, &of_dma_router_list, of_dma_routers)
+		if (ofrouter->of_node == np) {
+			list_del(&ofrouter->of_dma_routers);
+			kfree(ofrouter);
+			break;
+		}
+
+	mutex_unlock(&of_dma_router_lock);
+}
+EXPORT_SYMBOL_GPL(of_dma_router_free);
+
+/**
  * of_dma_match_channel - Check if a DMA specifier matches name
  * @np:		device node to look for DMA channels
  * @name:	channel name to be matched
diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h
index ae36298..50962a0 100644
--- a/include/linux/of_dma.h
+++ b/include/linux/of_dma.h
@@ -26,6 +26,12 @@ struct of_dma {
 	void			*of_dma_data;
 };
 
+struct of_dma_router {
+	struct list_head	of_dma_routers;
+	struct device_node	*of_node;
+	void			*of_router_data;
+};
+
 struct of_dma_filter_info {
 	dma_cap_mask_t	dma_cap;
 	dma_filter_fn	filter_fn;
@@ -41,6 +47,9 @@ extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
 						     const char *name);
 extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
 		struct of_dma *ofdma);
+extern void *of_dma_get_router_data(phandle router);
+extern int of_dma_router_register(struct device_node *np, void *data);
+extern void of_dma_router_free(struct device_node *np);
 #else
 static inline int of_dma_controller_register(struct device_node *np,
 		struct dma_chan *(*of_dma_xlate)
@@ -66,6 +75,19 @@ static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_s
 	return NULL;
 }
 
+static inline void *of_dma_get_router_data(phandle router)
+{
+	return NULL;
+}
+
+static inline int of_dma_router_register(struct device_node *np, void *data)
+{
+	return NULL;
+}
+
+static void of_dma_router_free(struct device_node *np)
+{
+}
 #endif
 
 #endif /* __LINUX_OF_DMA_H */
-- 
1.7.9.5

  parent reply	other threads:[~2014-03-07 12:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07 12:16 [RFC PATCH 0/9] drivers: dma: Add support for dma-channel router Sricharan R
2014-03-07 12:16 ` [RFC PATCH 1/9] drivers: dma: omap-dma: Avoid hard-coding of the dma-request channels Sricharan R
2014-03-07 12:16 ` Sricharan R [this message]
2014-03-07 12:16 ` [RFC PATCH 3/9] drivers: dma: omap-dma: Add a seperate xlate function to get router data Sricharan R
2014-03-07 12:16 ` [RFC PATCH 4/9] drivers: omap-dma: Add crossbar line as a resource to omap_chan structure Sricharan R
2014-03-07 12:16 ` [RFC PATCH 5/9] drivers: dma: Add dma crossbar driver Sricharan R
2014-03-07 12:16 ` [RFC PATCH 6/9] arm: dts: dra: Add dma crossbar node Sricharan R
2014-03-07 12:16 ` [RFC PATCH 7/9] arm: dts: dra: Add dma-request crossbar phandle to dma-specs Sricharan R
2014-03-07 12:16 ` [RFC PATCH 8/9] arm: dra: Enable dma crossbar support on dra7xx Sricharan R
2014-03-07 12:16 ` [RFC PATCH 9/9] arm: dts: dra7: Change the total dma-req numbers to crossbar channels Sricharan R
2014-03-08 19:53 ` [RFC PATCH 0/9] drivers: dma: Add support for dma-channel router Rob Herring
2014-03-10 13:58   ` Sricharan R

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=1394194576-23741-3-git-send-email-r.sricharan@ti.com \
    --to=r.sricharan@ti.com \
    --cc=dan.j.williams@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=nm@ti.com \
    --cc=nsekhar@ti.com \
    --cc=rnayak@ti.com \
    --cc=santosh.shilimkar@ti.com \
    --cc=tony@atomide.com \
    --cc=vinod.koul@intel.com \
    /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).