Re: [RFC PATCH 03/13] ARM: edma: add DT and runtime PM support for AM335x

2012-10-09 Thread Matt Porter
On Fri, Sep 21, 2012 at 08:53:06AM +, Hebbar, Gururaja wrote:
> On Thu, Sep 20, 2012 at 20:13:36, Porter, Matt wrote:
> > Adds support for parsing the TI EDMA DT data into the required
> > EDMA private API platform data.
> > 
> > Calls runtime PM API only in the DT case in order to unidle the
> > associated hwmods on AM335x.
> > 
> > Signed-off-by: Matt Porter 
> > ---
> >  arch/arm/common/edma.c   |  252 
> > --
> >  arch/arm/include/asm/mach/edma.h |8 +-
> >  2 files changed, 244 insertions(+), 16 deletions(-)
> 
> The binding documentation should be updated along with the driver
> change that does introduce the binding. You could just merged patch #4
> and #5.

Hi Gururaja,

Sorry I missed these comments for this long...

I've been asked by maintainers to keep the binding separate in other
drivers. It is documentation that is independent of the driver in
any case...I'll move the binding before this implementation though.

> > diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c
> > index 001d268..f337f81 100644
> > --- a/arch/arm/common/edma.c
> > +++ b/arch/arm/common/edma.c
> > @@ -24,6 +24,13 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> >  
> >  #include 
> >  
> > @@ -1366,30 +1373,236 @@ void edma_clear_event(unsigned channel)
> >  EXPORT_SYMBOL(edma_clear_event);
> >  
> >  /*---*/
> > +static int edma_of_read_u32_to_s8_array(const struct device_node *np,
> > +const char *propname, s8 *out_values,
> > +size_t sz)
> > +{
> > +   struct property *prop = of_find_property(np, propname, NULL);
> > +   const __be32 *val;
> > +
> > +   if (!prop)
> > +   return -EINVAL;
> > +   if (!prop->value)
> > +   return -ENODATA;
> > +   if ((sz * sizeof(u32)) > prop->length)
> > +   return -EOVERFLOW;
> > +
> > +   val = prop->value;
> > +
> > +   while (sz--)
> > +   *out_values++ = (s8)(be32_to_cpup(val++) & 0xff);
> > +
> > +   /* Terminate it */
> > +   *out_values++ = -1;
> > +   *out_values++ = -1;
> > +
> > +   return 0;
> > +}
> > +
> > +static int edma_of_read_u32_to_s16_array(const struct device_node *np,
> > +const char *propname, s16 *out_values,
> > +size_t sz)
> > +{
> > +   struct property *prop = of_find_property(np, propname, NULL);
> > +   const __be32 *val;
> > +
> > +   if (!prop)
> > +   return -EINVAL;
> > +   if (!prop->value)
> > +   return -ENODATA;
> > +   if ((sz * sizeof(u32)) > prop->length)
> > +   return -EOVERFLOW;
> > +
> > +   val = prop->value;
> > +
> > +   while (sz--)
> > +   *out_values++ = (s16)(be32_to_cpup(val++) & 0x);
> > +
> > +   /* Terminate it */
> > +   *out_values++ = -1;
> > +   *out_values++ = -1;
> > +
> > +   return 0;
> > +}
> > +
> > +static int edma_of_parse_dt(struct device *dev,
> > +   struct device_node *node,
> > +   struct edma_soc_info *pdata)
> > +{
> > +   int ret = 0;
> > +   u32 value;
> > +   struct property *prop;
> > +   size_t sz;
> > +   struct edma_rsv_info *rsv_info;
> > +   s16 (*rsv_chans)[2], (*rsv_slots)[2];
> > +   s8 (*queue_tc_map)[2], (*queue_priority_map)[2];
> > +
> > +   ret = of_property_read_u32(node, "dma-channels", &value);
> > +   if (ret < 0)
> > +   return ret;
> > +   pdata->n_channel = value;
> > +
> > +   ret = of_property_read_u32(node, "ti,edma-regions", &value);
> > +   if (ret < 0)
> > +   return ret;
> > +   pdata->n_region = value;
> > +
> > +   ret = of_property_read_u32(node, "ti,edma-slots", &value);
> > +   if (ret < 0)
> > +   return ret;
> > +   pdata->n_slot = value;
> > +
> > +   pdata->n_cc = 1;
> > +   /* This is unused */
> > +   pdata->n_tc = 3;
> > +
> > +   rsv_info =
> > +   devm_kzalloc(dev, sizeof(struct edma_rsv_info), GFP_KERNEL);
> > +   if (!rsv_info)
> > +   return -ENOMEM;
> > +   pdata->rsv = rsv_info;
> > +
> > +   /* Build the reserved channel/slots arrays */
> > +   prop = of_find_property(node, "ti,edma-reserved-channels", &sz);
> > +   if (!prop)
> > +   return -EINVAL;
> > +
> > +   rsv_chans =
> > +   devm_kzalloc(dev, sz/sizeof(s16) + 2*sizeof(s16), GFP_KERNEL);
> > +   if (!rsv_chans)
> > +   return -ENOMEM;
> > +   pdata->rsv->rsv_chans = rsv_chans;
> > +
> > +   ret = edma_of_read_u32_to_s16_array(node, "ti,edma-reserved-channels",
> > +   (s16 *)rsv_chans, sz/sizeof(u32));
> > +   if (ret < 0)
> > +   return ret;
> > +
> > +   prop = of_find_property(node, "ti,edma-reserved-slots", &sz);
> > +   if (!prop)
> > +   return -EINVAL;
> > +
> 
> Binding Documentation mentions edma-reserve

RE: [RFC PATCH 03/13] ARM: edma: add DT and runtime PM support for AM335x

2012-09-21 Thread Hebbar, Gururaja
On Thu, Sep 20, 2012 at 20:13:36, Porter, Matt wrote:
> Adds support for parsing the TI EDMA DT data into the required
> EDMA private API platform data.
> 
> Calls runtime PM API only in the DT case in order to unidle the
> associated hwmods on AM335x.
> 
> Signed-off-by: Matt Porter 
> ---
>  arch/arm/common/edma.c   |  252 
> --
>  arch/arm/include/asm/mach/edma.h |8 +-
>  2 files changed, 244 insertions(+), 16 deletions(-)

The binding documentation should be updated along with the driver
change that does introduce the binding. You could just merged patch #4
and #5.

> 
> diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c
> index 001d268..f337f81 100644
> --- a/arch/arm/common/edma.c
> +++ b/arch/arm/common/edma.c
> @@ -24,6 +24,13 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
>  
>  #include 
>  
> @@ -1366,30 +1373,236 @@ void edma_clear_event(unsigned channel)
>  EXPORT_SYMBOL(edma_clear_event);
>  
>  /*---*/
> +static int edma_of_read_u32_to_s8_array(const struct device_node *np,
> +  const char *propname, s8 *out_values,
> +  size_t sz)
> +{
> + struct property *prop = of_find_property(np, propname, NULL);
> + const __be32 *val;
> +
> + if (!prop)
> + return -EINVAL;
> + if (!prop->value)
> + return -ENODATA;
> + if ((sz * sizeof(u32)) > prop->length)
> + return -EOVERFLOW;
> +
> + val = prop->value;
> +
> + while (sz--)
> + *out_values++ = (s8)(be32_to_cpup(val++) & 0xff);
> +
> + /* Terminate it */
> + *out_values++ = -1;
> + *out_values++ = -1;
> +
> + return 0;
> +}
> +
> +static int edma_of_read_u32_to_s16_array(const struct device_node *np,
> +  const char *propname, s16 *out_values,
> +  size_t sz)
> +{
> + struct property *prop = of_find_property(np, propname, NULL);
> + const __be32 *val;
> +
> + if (!prop)
> + return -EINVAL;
> + if (!prop->value)
> + return -ENODATA;
> + if ((sz * sizeof(u32)) > prop->length)
> + return -EOVERFLOW;
> +
> + val = prop->value;
> +
> + while (sz--)
> + *out_values++ = (s16)(be32_to_cpup(val++) & 0x);
> +
> + /* Terminate it */
> + *out_values++ = -1;
> + *out_values++ = -1;
> +
> + return 0;
> +}
> +
> +static int edma_of_parse_dt(struct device *dev,
> + struct device_node *node,
> + struct edma_soc_info *pdata)
> +{
> + int ret = 0;
> + u32 value;
> + struct property *prop;
> + size_t sz;
> + struct edma_rsv_info *rsv_info;
> + s16 (*rsv_chans)[2], (*rsv_slots)[2];
> + s8 (*queue_tc_map)[2], (*queue_priority_map)[2];
> +
> + ret = of_property_read_u32(node, "dma-channels", &value);
> + if (ret < 0)
> + return ret;
> + pdata->n_channel = value;
> +
> + ret = of_property_read_u32(node, "ti,edma-regions", &value);
> + if (ret < 0)
> + return ret;
> + pdata->n_region = value;
> +
> + ret = of_property_read_u32(node, "ti,edma-slots", &value);
> + if (ret < 0)
> + return ret;
> + pdata->n_slot = value;
> +
> + pdata->n_cc = 1;
> + /* This is unused */
> + pdata->n_tc = 3;
> +
> + rsv_info =
> + devm_kzalloc(dev, sizeof(struct edma_rsv_info), GFP_KERNEL);
> + if (!rsv_info)
> + return -ENOMEM;
> + pdata->rsv = rsv_info;
> +
> + /* Build the reserved channel/slots arrays */
> + prop = of_find_property(node, "ti,edma-reserved-channels", &sz);
> + if (!prop)
> + return -EINVAL;
> +
> + rsv_chans =
> + devm_kzalloc(dev, sz/sizeof(s16) + 2*sizeof(s16), GFP_KERNEL);
> + if (!rsv_chans)
> + return -ENOMEM;
> + pdata->rsv->rsv_chans = rsv_chans;
> +
> + ret = edma_of_read_u32_to_s16_array(node, "ti,edma-reserved-channels",
> + (s16 *)rsv_chans, sz/sizeof(u32));
> + if (ret < 0)
> + return ret;
> +
> + prop = of_find_property(node, "ti,edma-reserved-slots", &sz);
> + if (!prop)
> + return -EINVAL;
> +

Binding Documentation mentions edma-reserved-[channels/slots] as optional. 
But here the code returns as error if they are not found. Kindly reconfirm

>From patch-set 5/13

+Optional properties:
+- ti,edma-reserved-channels: List of reserved channel regions
+- ti,edma-reserved-slots: List of reserved slot regions

> + rsv_slots = devm_kzalloc(dev,
> +  sz/sizeof(s16) + 2*sizeof(s16),
> +  GFP_KERNEL);
> + if (!rsv_slots)
> + return -

[RFC PATCH 03/13] ARM: edma: add DT and runtime PM support for AM335x

2012-09-20 Thread Matt Porter
Adds support for parsing the TI EDMA DT data into the required
EDMA private API platform data.

Calls runtime PM API only in the DT case in order to unidle the
associated hwmods on AM335x.

Signed-off-by: Matt Porter 
---
 arch/arm/common/edma.c   |  252 --
 arch/arm/include/asm/mach/edma.h |8 +-
 2 files changed, 244 insertions(+), 16 deletions(-)

diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c
index 001d268..f337f81 100644
--- a/arch/arm/common/edma.c
+++ b/arch/arm/common/edma.c
@@ -24,6 +24,13 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 
@@ -1366,30 +1373,236 @@ void edma_clear_event(unsigned channel)
 EXPORT_SYMBOL(edma_clear_event);
 
 /*---*/
+static int edma_of_read_u32_to_s8_array(const struct device_node *np,
+const char *propname, s8 *out_values,
+size_t sz)
+{
+   struct property *prop = of_find_property(np, propname, NULL);
+   const __be32 *val;
+
+   if (!prop)
+   return -EINVAL;
+   if (!prop->value)
+   return -ENODATA;
+   if ((sz * sizeof(u32)) > prop->length)
+   return -EOVERFLOW;
+
+   val = prop->value;
+
+   while (sz--)
+   *out_values++ = (s8)(be32_to_cpup(val++) & 0xff);
+
+   /* Terminate it */
+   *out_values++ = -1;
+   *out_values++ = -1;
+
+   return 0;
+}
+
+static int edma_of_read_u32_to_s16_array(const struct device_node *np,
+const char *propname, s16 *out_values,
+size_t sz)
+{
+   struct property *prop = of_find_property(np, propname, NULL);
+   const __be32 *val;
+
+   if (!prop)
+   return -EINVAL;
+   if (!prop->value)
+   return -ENODATA;
+   if ((sz * sizeof(u32)) > prop->length)
+   return -EOVERFLOW;
+
+   val = prop->value;
+
+   while (sz--)
+   *out_values++ = (s16)(be32_to_cpup(val++) & 0x);
+
+   /* Terminate it */
+   *out_values++ = -1;
+   *out_values++ = -1;
+
+   return 0;
+}
+
+static int edma_of_parse_dt(struct device *dev,
+   struct device_node *node,
+   struct edma_soc_info *pdata)
+{
+   int ret = 0;
+   u32 value;
+   struct property *prop;
+   size_t sz;
+   struct edma_rsv_info *rsv_info;
+   s16 (*rsv_chans)[2], (*rsv_slots)[2];
+   s8 (*queue_tc_map)[2], (*queue_priority_map)[2];
+
+   ret = of_property_read_u32(node, "dma-channels", &value);
+   if (ret < 0)
+   return ret;
+   pdata->n_channel = value;
+
+   ret = of_property_read_u32(node, "ti,edma-regions", &value);
+   if (ret < 0)
+   return ret;
+   pdata->n_region = value;
+
+   ret = of_property_read_u32(node, "ti,edma-slots", &value);
+   if (ret < 0)
+   return ret;
+   pdata->n_slot = value;
+
+   pdata->n_cc = 1;
+   /* This is unused */
+   pdata->n_tc = 3;
+
+   rsv_info =
+   devm_kzalloc(dev, sizeof(struct edma_rsv_info), GFP_KERNEL);
+   if (!rsv_info)
+   return -ENOMEM;
+   pdata->rsv = rsv_info;
+
+   /* Build the reserved channel/slots arrays */
+   prop = of_find_property(node, "ti,edma-reserved-channels", &sz);
+   if (!prop)
+   return -EINVAL;
+
+   rsv_chans =
+   devm_kzalloc(dev, sz/sizeof(s16) + 2*sizeof(s16), GFP_KERNEL);
+   if (!rsv_chans)
+   return -ENOMEM;
+   pdata->rsv->rsv_chans = rsv_chans;
+
+   ret = edma_of_read_u32_to_s16_array(node, "ti,edma-reserved-channels",
+   (s16 *)rsv_chans, sz/sizeof(u32));
+   if (ret < 0)
+   return ret;
+
+   prop = of_find_property(node, "ti,edma-reserved-slots", &sz);
+   if (!prop)
+   return -EINVAL;
+
+   rsv_slots = devm_kzalloc(dev,
+sz/sizeof(s16) + 2*sizeof(s16),
+GFP_KERNEL);
+   if (!rsv_slots)
+   return -ENOMEM;
+   pdata->rsv->rsv_slots = rsv_slots;
+
+   ret = edma_of_read_u32_to_s16_array(node,
+   "ti,edma-reserved-slots",
+   (s16 *)rsv_slots,
+   sz/sizeof(u32));
+   if (ret < 0)
+   return ret;
+
+   prop = of_find_property(node, "ti,edma-queue-tc-map", &sz);
+   if (!prop)
+   return -EINVAL;
+
+   queue_tc_map = devm_kzalloc(dev,
+   sz/sizeof(s8) + 2*sizeof(s8),
+   GFP_KERNEL);
+   if (!rsv_slots)
+