From: Jon Hunter <hidden> Date: 2012-09-13 22:00:27
This is based upon the work by Benoit Cousson [1] and Nicolas Ferre [2] to add
some basic device-tree helpers to retrieve a DMA controller device_node and the
DMA request/channel information.
[1] http://article.gmane.org/gmane.linux.drivers.devicetree/12022
[2] http://article.gmane.org/gmane.linux.ports.arm.omap/73622
Cc: Nicolas Ferre <redacted>
Cc: Benoit Cousson <redacted>
Cc: Stephen Warren <redacted>
Cc: Grant Likely <redacted>
Cc: Russell King <redacted>
Cc: Rob Herring <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Vinod Koul <redacted>
Cc: Dan Williams <redacted>
Jon Hunter (2):
of: Add generic device tree DMA helpers
dmaengine: add helper function to request a slave DMA channel
Documentation/devicetree/bindings/dma/dma.txt | 62 +++++++
drivers/dma/dmaengine.c | 16 ++
drivers/of/Makefile | 2 +-
drivers/of/dma.c | 215 +++++++++++++++++++++++++
include/linux/dmaengine.h | 6 +
include/linux/of_dma.h | 45 ++++++
6 files changed, 345 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/dma/dma.txt
create mode 100644 drivers/of/dma.c
create mode 100644 include/linux/of_dma.h
--
1.7.9.5
From: Jon Hunter <hidden> Date: 2012-09-13 22:00:28
This is based upon the work by Benoit Cousson [1] and Nicolas Ferre [2]
to add some basic helpers to retrieve a DMA controller device_node and the
DMA request/channel information.
Aim of DMA helpers
- The purpose of device-tree is to describe the capabilites of the hardware.
Thinking about DMA controllers purely from the context of the hardware to
begin with, we can describe a device in terms of a DMA controller as
follows ...
1. Number of DMA controllers
2. Number of channels (maybe physical or logical)
3. Mapping of DMA requests signals to DMA controller
4. Number of DMA interrupts
5. Mapping of DMA interrupts to channels
- With the above in mind the aim of the DT DMA helper functions is to extract
the above information from the DT and provide to the appropriate driver.
However, due to the vast number of DMA controllers and not all are using a
common driver (such as DMA Engine) it has been seen that this is not a
trivial task. In previous discussions on this topic the following concerns
have been raised ...
1. How does the binding support devices with multiple DMA controllers?
2. How to support both legacy DMA controllers not using DMA Engine as
well as those that support DMA Engine.
3. When using with DMA Engine how do we support the various
implementations where the opaque filter function parameter differs
between implementations?
4. How do we handle DMA channels that are identified with a string
versus a integer?
- Hence the design of the DMA helpers has to accomodate the above or align on
an agreement what can be or should be supported.
Design of DMA helpers
1. Registering DMA controllers
In the case of DMA controllers that are using DMA Engine, requesting a
channel is performed by calling the following function.
struct dma_chan *dma_request_channel(dma_cap_mask_t mask,
dma_filter_fn filter_fn,
void *filter_param);
The mask variable is used to match a type of the device controller in a list
of controllers. The filter_fn and filter_param are used to identify the
required dma channel and return a handle to the dma channel of type dma_chan.
From the examples I have seen, the mask and filter_fn are constant
for a given DMA controller and therefore, we can specify these as controller
specific data when registering the DMA controller with the device-tree DMA
helpers.
The filter_param variable is of an unknown type and is typically specific
to the DMA engine implementation for a given DMA controller. To allow some
flexibility in the type and formating of this filter_param we employ an
xlate to translate the device-tree binding information into the appropriate
format. The xlate function used for a DMA controller can also be specified
when registering the DMA controller with the device-tree DMA helpers.
Based upon the above, a function for registering the DMA controller with the
DMA helpers now looks like the below. The data variable is used to pass a
pointer to DMA controller specific data used by the xlate function.
int of_dma_controller_register(struct device_node *np,
struct dma_chan *(*of_dma_xlate)
(struct of_phandle_args *, struct of_dma *),
void *data)
For example, in the case where DMA engine is used, we define the following
structure (that stores the DMA engine capability mask and filter function)
and pass this to the data variable in the above function.
struct of_dma_filter_info {
dma_cap_mask_t dma_cap;
dma_filter_fn filter_fn;
};
2. Representing and requesting channel information
Please see the dma binding documentation included in this patch for a
description of how DMA controllers and client information should be
represented with device-tree. For more information on how this binding
came about please see [3]. In addition to this, feedback received from
the Linux kernel summit showed a consensus (among those who attended) to
use a name to identify DMA client information [4].
A DMA channel can be requested by calling the following function, where name
is a required parameter used for identifying a DMA channel. This function
has been designed to return a structure of type dma_chan to work with the
DMA engine driver. Note that if DMA engine is used then drivers should be
using the DMA engine API dma_request_slave_channel() (implemented in part 2
of this series, "dmaengine: add helper function to request a slave DMA
channel") which will in turn call the below function if device-tree is
present. The aim being to have a common DMA engine interface regardless of
whether device tree is being used.
struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
char *name)
3. Supporting legacy devices not using DMA Engine
These devices present a problem, as there may not be a uniform way to easily
support them with regard to device tree. Ideally, these should be migrated
to DMA engine. However, if this is not possible, then they should still be
able to use this binding, the only constaint imposed by this implementation
is that when requesting a DMA channel via of_dma_request_slave_channel(), it
will return a type of dma_chan.
This implementation has been tested on OMAP4430 using the kernel v3.6-rc5. I
have validated that MMC is working on the PANDA board with this implementation.
My development branch for testing on OMAP can be found here [5].
v4: - revert the removal of xlate function from v3
- update the proposed binding format and APIs based upon discussions [3]
v3: - avoid passing an xlate function and instead pass DMA engine parameters
- define number of dma channels and requests in dma-controller node
v2: - remove of_dma_to_resource API
- make property #dma-cells required (no fallback anymore)
- another check in of_dma_xlate_onenumbercell() function
[1] http://article.gmane.org/gmane.linux.drivers.devicetree/12022
[2] http://article.gmane.org/gmane.linux.ports.arm.omap/73622
[3] http://marc.info/?l=linux-omap&m=133582085008539&w=2
[4] http://pad.linaro.org/arm-mini-summit-2012
[5] https://github.com/jonhunter/linux/tree/dev-dt-dma
Cc: Nicolas Ferre <redacted>
Cc: Benoit Cousson <redacted>
Cc: Stephen Warren <redacted>
Cc: Grant Likely <redacted>
Cc: Russell King <redacted>
Cc: Rob Herring <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Vinod Koul <redacted>
Cc: Dan Williams <redacted>
Signed-off-by: Jon Hunter <redacted>
---
Documentation/devicetree/bindings/dma/dma.txt | 62 +++++++
drivers/of/Makefile | 2 +-
drivers/of/dma.c | 215 +++++++++++++++++++++++++
include/linux/of_dma.h | 45 ++++++
4 files changed, 323 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/dma/dma.txt
create mode 100644 drivers/of/dma.c
create mode 100644 include/linux/of_dma.h
@@ -0,0 +1,62 @@+* Generic DMA Controller and DMA request bindings++Generic binding to provide a way for a driver using DMA Engine to retrieve the+DMA request or channel information that goes from a hardware device to a DMA+controller.+++* DMA controller++Required property:+- #dma-cells: Must be at least 1. Used to provide DMA controller+ specific information. See DMA client binding below for+ more details.++Optional properties:+- #dma-channels: Number of DMA channels supported by the controller.+- #dma-requests: Number of DMA requests signals supported by the+ controller.++Example:++ sdma: dmaengine at 48000000 {+ compatible = "ti,omap-sdma"+ reg = <0x48000000 0x1000>;+ interrupts = <0 12 0x4+ 0 13 0x4+ 0 14 0x4+ 0 15 0x4>;+ #dma-cells = <1>;+ #dma-channels = <32>;+ #dma-requests = <127>;+ };+++* DMA client++Client drivers should specify the DMA property using a phandle to the controller+followed by DMA controller specific data.++Required property:+- dmas: List of one or more DMA specifiers, each consisting of+ - A phandle pointing to DMA controller node+ - A single integer cell containing DMA controller+ specific information. This typically contains a dma+ request line number or a channel number, but can+ contain any data that is used required for configuring+ a channel.+- dma-names: Contains one identifier string for each dma specifier in+ the dmas property. The specific strings that can be used+ are defined in the binding of the DMA client device.++Example:++- One DMA write channel, one DMA read/write channel:++ i2c1: i2c at 1 {+ ...+ dmas = <&sdma 2 /* read channel */+ &sdma 3>; /* write channel */+ dma-names = "rx", "tx"+ ...+ };
@@ -0,0 +1,215 @@+/*+*DevicetreehelpersforDMArequest/controller+*+*Basedonof_gpio.c+*+*Copyright(C)2012TexasInstrumentsIncorporated-http://www.ti.com/+*+*Thisprogramisfreesoftware;youcanredistributeitand/ormodify+*itunderthetermsoftheGNUGeneralPublicLicenseversion2as+*publishedbytheFreeSoftwareFoundation.+*/++#include<linux/device.h>+#include<linux/err.h>+#include<linux/module.h>+#include<linux/rculist.h>+#include<linux/slab.h>+#include<linux/of.h>+#include<linux/of_dma.h>++staticLIST_HEAD(of_dma_list);++/**+*of_dma_find_controller-FindaDMAcontrollerinDTDMAhelperslist+*@np:devicenodeofDMAcontroller+*/+staticstructof_dma*of_dma_find_controller(structdevice_node*np)+{+structof_dma*ofdma;++if(list_empty(&of_dma_list)){+pr_err("empty DMA controller list\n");+returnNULL;+}++list_for_each_entry_rcu(ofdma,&of_dma_list,of_dma_controllers)+if(ofdma->of_node==np)+returnofdma;++returnNULL;+}++/**+*of_dma_controller_register-RegisteraDMAcontrollertoDTDMAhelpers+*@np:devicenodeofDMAcontroller+*@of_dma_xlate:translationfunctionwhichconvertsaphandle+*argumentslistintoadma_chanstructure+*@datapointertocontrollerspecificdatatobeusedby+*translationfunction+*+*Returns0onsuccessorappropriateerrnovalueonerror.+*+*Allocatedmemoryshouldbefreedwithappropriateof_dma_controller_free()+*call.+*/+intof_dma_controller_register(structdevice_node*np,+structdma_chan*(*of_dma_xlate)+(structof_phandle_args*,structof_dma*),+void*data)+{+structof_dma*ofdma;+intnbcells;++if(!np||!of_dma_xlate){+pr_err("%s: not enough information provided\n",__func__);+return-EINVAL;+}++ofdma=kzalloc(sizeof(*ofdma),GFP_KERNEL);+if(!ofdma)+return-ENOMEM;++nbcells=be32_to_cpup(of_get_property(np,"#dma-cells",NULL));+if(!nbcells){+pr_err("%s: #dma-cells property is missing or invalid\n",+__func__);+return-EINVAL;+}++ofdma->of_node=np;+ofdma->of_dma_nbcells=nbcells;+ofdma->of_dma_xlate=of_dma_xlate;+ofdma->of_dma_data=data;++/* Now queue of_dma controller structure in list */+list_add_tail_rcu(&ofdma->of_dma_controllers,&of_dma_list);++return0;+}+EXPORT_SYMBOL_GPL(of_dma_controller_register);++/**+*of_dma_controller_free-RemoveaDMAcontrollerfromDTDMAhelperslist+*@np:devicenodeofDMAcontroller+*+*Memoryallocatedbyof_dma_controller_register()isfreedhere.+*/+voidof_dma_controller_free(structdevice_node*np)+{+structof_dma*ofdma;++ofdma=of_dma_find_controller(np);+if(ofdma){+list_del_rcu(&ofdma->of_dma_controllers);+kfree(ofdma);+}+}+EXPORT_SYMBOL_GPL(of_dma_controller_free);++/**+*of_dma_find_channel-FindaDMAchannelbyname+*@np:devicenodetolookforDMAchannels+*@name:nameofdesiredchannel+*@dma_spec:pointertoDMAspecifierasfoundinthedevicetree+*+*FindaDMAchannelbythename.Returns0onsuccessorappropriate+*errnovalueonerror.+*/+staticintof_dma_find_channel(structdevice_node*np,char*name,+structof_phandle_args*dma_spec)+{+intcount,i;+constchar*s;++count=of_property_count_strings(np,"dma-names");+if(count<0)+returncount;++for(i=0;i<count;i++){+of_property_read_string_index(np,"dma-names",i,&s);++if(strcmp(name,s))+continue;++returnof_parse_phandle_with_args(np,"dmas","#dma-cells",+i,dma_spec);+}++return-ENODEV;+}++/**+*of_dma_request_slave_channel-GettheDMAslavechannel+*@np:devicenodetogetDMArequestfrom+*@name:nameofdesiredchannel+*+*ReturnspointertoappropriatedmachannelonsuccessorNULLonerror.+*/+structdma_chan*of_dma_request_slave_channel(structdevice_node*np,+char*name)+{+structof_phandle_argsdma_spec;+structof_dma*ofdma;+structdma_chan*chan;+intr;++if(!np||!name){+pr_err("%s: not enough information provided\n",__func__);+returnNULL;+}++r=of_dma_find_channel(np,name,&dma_spec);++if(r){+pr_err("%s: can't find DMA channel\n",np->full_name);+returnNULL;+}++ofdma=of_dma_find_controller(dma_spec.np);+if(!ofdma){+pr_err("%s: can't find DMA controller %s\n",np->full_name,+dma_spec.np->full_name);+returnNULL;+}++if(dma_spec.args_count!=ofdma->of_dma_nbcells){+pr_err("%s: wrong #dma-cells for %s\n",np->full_name,+dma_spec.np->full_name);+returnNULL;+}++chan=ofdma->of_dma_xlate(&dma_spec,ofdma);++of_node_put(dma_spec.np);++returnchan;+}+EXPORT_SYMBOL_GPL(of_dma_request_slave_channel);++/**+*of_dma_simple_xlate-SimpleDMAenginetranslationfunction+*@dma_spec:pointertoDMAspecifierasfoundinthedevicetree+*@of_dma:pointertoDMAcontrollerdata+*+*Asimpletranslationfunctionfordevicesthatusea32-bitvalueforthe+*filter_paramwhencallingtheDMAenginedma_request_channel()function.+*Notethatthistranslationfunctionrequiresthat#dma-cellsisequalto1+*andtheargumentofthedmaspecifieristhe32-bitfilter_param.Returns+*pointertoappropriatedmachannelonsuccessorNULLonerror.+*/+structdma_chan*of_dma_simple_xlate(structof_phandle_args*dma_spec,+structof_dma*ofdma)+{+intcount=dma_spec->args_count;+structof_dma_filter_info*info=ofdma->of_dma_data;++if(!info||!info->filter_fn)+returnNULL;++if(count!=1)+returnNULL;++returndma_request_channel(info->dma_cap,info->filter_fn,+&dma_spec->args[0]);+}
From: Jon Hunter <hidden> Date: 2012-09-13 22:00:29
Currently slave DMA channels are requested by calling dma_request_channel()
and requires DMA clients to pass various filter parameters to obtain the
appropriate channel.
With device-tree being used by architectures such as arm and the addition of
device-tree helper functions to extract the relevant DMA client information
from device-tree, add a new function to request a slave DMA channel using
device-tree. This function is currently a simple wrapper that calls the
device-tree of_dma_request_slave_channel() function.
Cc: Nicolas Ferre <redacted>
Cc: Benoit Cousson <redacted>
Cc: Stephen Warren <redacted>
Cc: Grant Likely <redacted>
Cc: Russell King <redacted>
Cc: Rob Herring <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Vinod Koul <redacted>
Cc: Dan Williams <redacted>
Signed-off-by: Jon Hunter <redacted>
---
drivers/dma/dmaengine.c | 16 ++++++++++++++++
include/linux/dmaengine.h | 6 ++++++
2 files changed, 22 insertions(+)
@@ -546,6 +547,21 @@ struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, v}EXPORT_SYMBOL_GPL(__dma_request_channel);+/**+*dma_request_slave_channel-trytoallocateanexclusiveslavechannel+*@dev:pointertoclientdevicestructure+*@name:slavechannelname+*/+structdma_chan*dma_request_slave_channel(structdevice*dev,char*name)+{+/* If device-tree is present get slave info from here */+if(dev->of_node)+returnof_dma_request_slave_channel(dev->of_node,name);++returnNULL;+}+EXPORT_SYMBOL_GPL(dma_request_slave_channel);+voiddma_release_channel(structdma_chan*chan){mutex_lock(&dma_list_mutex);
This is based upon the work by Benoit Cousson [1] and Nicolas Ferre [2]
to add some basic helpers to retrieve a DMA controller device_node and the
DMA request/channel information.
I think we're getting very close now, I only have a few small comments left
that should all be uncontroversial.
+
+Client drivers should specify the DMA property using a phandle to the controller
+followed by DMA controller specific data.
+
+Required property:
+- dmas: List of one or more DMA specifiers, each consisting of
+ - A phandle pointing to DMA controller node
+ - A single integer cell containing DMA controller
+ specific information. This typically contains a dma
+ request line number or a channel number, but can
+ contain any data that is used required for configuring
+ a channel.
+- dma-names: Contains one identifier string for each dma specifier in
+ the dmas property. The specific strings that can be used
+ are defined in the binding of the DMA client device.
I think here we need to clarify that listing the same name multiple times implies
having multiple alternatives for the same channel.
+/**
+ * of_dma_find_channel - Find a DMA channel by name
+ * @np: device node to look for DMA channels
+ * @name: name of desired channel
+ * @dma_spec: pointer to DMA specifier as found in the device tree
+ *
+ * Find a DMA channel by the name. Returns 0 on success or appropriate
+ * errno value on error.
+ */
+static int of_dma_find_channel(struct device_node *np, char *name,
+ struct of_phandle_args *dma_spec)
+{
+ int count, i;
+ const char *s;
+
+ count = of_property_count_strings(np, "dma-names");
+ if (count < 0)
+ return count;
+
+ for (i = 0; i < count; i++) {
+ of_property_read_string_index(np, "dma-names", i, &s);
+
+ if (strcmp(name, s))
+ continue;
+
+ return of_parse_phandle_with_args(np, "dmas", "#dma-cells",
+ i, dma_spec);
+ }
+
+ return -ENODEV;
+}
I think we should at least keep trying the other channels with the same name when
of_parse_phandle_with_args fails. We might want to do something smarter in
the long run, e.g. to spread channel allocations across the avaialable controllers.
+/**
+ * of_dma_request_slave_channel - Get the DMA slave channel
+ * @np: device node to get DMA request from
+ * @name: name of desired channel
+ *
+ * Returns pointer to appropriate dma channel on success or NULL on error.
+ */
+struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
+ char *name)
+{
...
+}
+EXPORT_SYMBOL_GPL(of_dma_request_slave_channel);
I think this no longer needs to be exported, with patch 2 on top.
+/**
+ * of_dma_simple_xlate - Simple DMA engine translation function
+ * @dma_spec: pointer to DMA specifier as found in the device tree
+ * @of_dma: pointer to DMA controller data
+ *
+ * A simple translation function for devices that use a 32-bit value for the
+ * filter_param when calling the DMA engine dma_request_channel() function.
+ * Note that this translation function requires that #dma-cells is equal to 1
+ * and the argument of the dma specifier is the 32-bit filter_param. Returns
+ * pointer to appropriate dma channel on success or NULL on error.
+ */
+struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
+ struct of_dma *ofdma)
+{
+ int count = dma_spec->args_count;
+ struct of_dma_filter_info *info = ofdma->of_dma_data;
+
+ if (!info || !info->filter_fn)
+ return NULL;
+
+ if (count != 1)
+ return NULL;
+
+ return dma_request_channel(info->dma_cap, info->filter_fn,
+ &dma_spec->args[0]);
+}
From: Jon Hunter <hidden> Date: 2012-09-14 13:27:16
Hi Arnd,
On 09/14/2012 04:43 AM, Arnd Bergmann wrote:
On Thursday 13 September 2012, Jon Hunter wrote:
quoted
This is based upon the work by Benoit Cousson [1] and Nicolas Ferre [2]
to add some basic helpers to retrieve a DMA controller device_node and the
DMA request/channel information.
I think we're getting very close now, I only have a few small comments left
that should all be uncontroversial.
quoted
+
+Client drivers should specify the DMA property using a phandle to the controller
+followed by DMA controller specific data.
+
+Required property:
+- dmas: List of one or more DMA specifiers, each consisting of
+ - A phandle pointing to DMA controller node
+ - A single integer cell containing DMA controller
+ specific information. This typically contains a dma
+ request line number or a channel number, but can
+ contain any data that is used required for configuring
+ a channel.
+- dma-names: Contains one identifier string for each dma specifier in
+ the dmas property. The specific strings that can be used
+ are defined in the binding of the DMA client device.
I think here we need to clarify that listing the same name multiple times implies
having multiple alternatives for the same channel.
Ok, however, the way it works right now is that we will use the first
specifier that matches the name. So if there are multiple with the same
name that would imply that someone will need call the
xxx_request_slave_channel() multiple times to extract these. Is that ok?
+/**
+ * of_dma_find_channel - Find a DMA channel by name
+ * @np: device node to look for DMA channels
+ * @name: name of desired channel
+ * @dma_spec: pointer to DMA specifier as found in the device tree
+ *
+ * Find a DMA channel by the name. Returns 0 on success or appropriate
+ * errno value on error.
+ */
+static int of_dma_find_channel(struct device_node *np, char *name,
+ struct of_phandle_args *dma_spec)
+{
+ int count, i;
+ const char *s;
+
+ count = of_property_count_strings(np, "dma-names");
+ if (count < 0)
+ return count;
+
+ for (i = 0; i < count; i++) {
+ of_property_read_string_index(np, "dma-names", i, &s);
+
+ if (strcmp(name, s))
+ continue;
+
+ return of_parse_phandle_with_args(np, "dmas", "#dma-cells",
+ i, dma_spec);
+ }
+
+ return -ENODEV;
+}
I think we should at least keep trying the other channels with the same name when
of_parse_phandle_with_args fails. We might want to do something smarter in
the long run, e.g. to spread channel allocations across the avaialable controllers.
Ok, can add this.
quoted
+/**
+ * of_dma_request_slave_channel - Get the DMA slave channel
+ * @np: device node to get DMA request from
+ * @name: name of desired channel
+ *
+ * Returns pointer to appropriate dma channel on success or NULL on error.
+ */
+struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
+ char *name)
+{
...
+}
+EXPORT_SYMBOL_GPL(of_dma_request_slave_channel);
I think this no longer needs to be exported, with patch 2 on top.
Right, I was in two minds but I can remove this.
quoted
+/**
+ * of_dma_simple_xlate - Simple DMA engine translation function
+ * @dma_spec: pointer to DMA specifier as found in the device tree
+ * @of_dma: pointer to DMA controller data
+ *
+ * A simple translation function for devices that use a 32-bit value for the
+ * filter_param when calling the DMA engine dma_request_channel() function.
+ * Note that this translation function requires that #dma-cells is equal to 1
+ * and the argument of the dma specifier is the 32-bit filter_param. Returns
+ * pointer to appropriate dma channel on success or NULL on error.
+ */
+struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
+ struct of_dma *ofdma)
+{
+ int count = dma_spec->args_count;
+ struct of_dma_filter_info *info = ofdma->of_dma_data;
+
+ if (!info || !info->filter_fn)
+ return NULL;
+
+ if (count != 1)
+ return NULL;
+
+ return dma_request_channel(info->dma_cap, info->filter_fn,
+ &dma_spec->args[0]);
+}
+
+Client drivers should specify the DMA property using a phandle to the controller
+followed by DMA controller specific data.
+
+Required property:
+- dmas: List of one or more DMA specifiers, each consisting of
+ - A phandle pointing to DMA controller node
+ - A single integer cell containing DMA controller
+ specific information. This typically contains a dma
+ request line number or a channel number, but can
+ contain any data that is used required for configuring
+ a channel.
+- dma-names: Contains one identifier string for each dma specifier in
+ the dmas property. The specific strings that can be used
+ are defined in the binding of the DMA client device.
I think here we need to clarify that listing the same name multiple times implies
having multiple alternatives for the same channel.
Ok, however, the way it works right now is that we will use the first
specifier that matches the name. So if there are multiple with the same
name that would imply that someone will need call the
xxx_request_slave_channel() multiple times to extract these. Is that ok?
I would expect a driver to only call the function once, and get something
back from the dmaengine layer that works. If there are two controllers
to choose from and one is busy, then it should definitely give a channel
from the non-busy one.
It's not much of an issue if the code doesn't handle all corner cases at
first, but I would expect that the binding correctly describes how to write
a device tree that will work once the code implements it correctly.
Arnd
From: Jon Hunter <hidden> Date: 2012-09-14 14:03:18
On 09/14/2012 08:32 AM, Arnd Bergmann wrote:
On Friday 14 September 2012, Jon Hunter wrote:
quoted
On 09/14/2012 04:43 AM, Arnd Bergmann wrote:
quoted
quoted
+
+Client drivers should specify the DMA property using a phandle to the controller
+followed by DMA controller specific data.
+
+Required property:
+- dmas: List of one or more DMA specifiers, each consisting of
+ - A phandle pointing to DMA controller node
+ - A single integer cell containing DMA controller
+ specific information. This typically contains a dma
+ request line number or a channel number, but can
+ contain any data that is used required for configuring
+ a channel.
+- dma-names: Contains one identifier string for each dma specifier in
+ the dmas property. The specific strings that can be used
+ are defined in the binding of the DMA client device.
I think here we need to clarify that listing the same name multiple times implies
having multiple alternatives for the same channel.
Ok, however, the way it works right now is that we will use the first
specifier that matches the name. So if there are multiple with the same
name that would imply that someone will need call the
xxx_request_slave_channel() multiple times to extract these. Is that ok?
I would expect a driver to only call the function once, and get something
back from the dmaengine layer that works. If there are two controllers
to choose from and one is busy, then it should definitely give a channel
from the non-busy one.
It's not much of an issue if the code doesn't handle all corner cases at
first, but I would expect that the binding correctly describes how to write
a device tree that will work once the code implements it correctly.
Gotcha, may be something like the following should work then ...
From: Stephen Warren <hidden> Date: 2012-09-14 16:28:57
On 09/13/2012 04:00 PM, Jon Hunter wrote:
This is based upon the work by Benoit Cousson [1] and Nicolas Ferre [2]
to add some basic helpers to retrieve a DMA controller device_node and the
DMA request/channel information.
+* Generic DMA Controller and DMA request bindings
+
+Generic binding to provide a way for a driver using DMA Engine to retrieve the
+DMA request or channel information that goes from a hardware device to a DMA
+controller.
+
+
+* DMA controller
+
+Required property:
+- #dma-cells: Must be at least 1. Used to provide DMA controller
+ specific information. See DMA client binding below for
...
+* DMA client
+
+Client drivers should specify the DMA property using a phandle to the controller
+followed by DMA controller specific data.
+
+Required property:
+- dmas: List of one or more DMA specifiers, each consisting of
+ - A phandle pointing to DMA controller node
+ - A single integer cell containing DMA controller
+ specific information. This typically contains a dma
+ request line number or a channel number, but can
+ contain any data that is used required for configuring
+ a channel.
"A single integer cell" doesn't sound correct; shouldn't this be
something like "a number of integer cells, as determined by the
#dma-cells property in the node referenced by phandle"?
+- dma-names: Contains one identifier string for each dma specifier in
+ the dmas property. The specific strings that can be used
+ are defined in the binding of the DMA client device.
From: Jon Hunter <hidden> Date: 2012-09-14 17:19:04
On 09/14/2012 11:28 AM, Stephen Warren wrote:
On 09/13/2012 04:00 PM, Jon Hunter wrote:
quoted
This is based upon the work by Benoit Cousson [1] and Nicolas Ferre [2]
to add some basic helpers to retrieve a DMA controller device_node and the
DMA request/channel information.
+* Generic DMA Controller and DMA request bindings
+
+Generic binding to provide a way for a driver using DMA Engine to retrieve the
+DMA request or channel information that goes from a hardware device to a DMA
+controller.
+
+
+* DMA controller
+
+Required property:
+- #dma-cells: Must be at least 1. Used to provide DMA controller
+ specific information. See DMA client binding below for
...
quoted
+* DMA client
+
+Client drivers should specify the DMA property using a phandle to the controller
+followed by DMA controller specific data.
+
+Required property:
+- dmas: List of one or more DMA specifiers, each consisting of
+ - A phandle pointing to DMA controller node
+ - A single integer cell containing DMA controller
+ specific information. This typically contains a dma
+ request line number or a channel number, but can
+ contain any data that is used required for configuring
+ a channel.
"A single integer cell" doesn't sound correct; shouldn't this be
something like "a number of integer cells, as determined by the
#dma-cells property in the node referenced by phandle"?
Thanks for catching that. I had been re-working this a few times and
must have forgotten to update that.
Cheers
Jon