diff mbox

[v11,3/8] ARM: edma: Add EDMA crossbar event mux support

Message ID 1371537499-12970-4-git-send-email-joelagnel@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fernandes, Joel A June 18, 2013, 6:38 a.m. UTC
From: Matt Porter <mporter@ti.com>

Changes by Joel:
* Split EDMA xbar support out of original EDMA DT parsing patch
to keep it easier for review.
* Rewrite shift and offset calculation.

Suggested-by: Sekhar Nori <nsekhar@ti.com>
Suggested by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Joel A Fernandes <joelagnel@ti.com>

Reference:
[1] https://patchwork.kernel.org/patch/2226991/
---
 arch/arm/common/edma.c             |   59 ++++++++++++++++++++++++++++++++++++
 include/linux/platform_data/edma.h |    1 +
 2 files changed, 60 insertions(+)

Comments

Sekhar Nori June 18, 2013, 10:19 a.m. UTC | #1
On 6/18/2013 12:08 PM, Joel A Fernandes wrote:
> From: Matt Porter <mporter@ti.com>
> 
> Changes by Joel:
> * Split EDMA xbar support out of original EDMA DT parsing patch
> to keep it easier for review.
> * Rewrite shift and offset calculation.
> 
> Suggested-by: Sekhar Nori <nsekhar@ti.com>
> Suggested by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
> 
> Reference:
> [1] https://patchwork.kernel.org/patch/2226991/
> ---
>  arch/arm/common/edma.c             |   59 ++++++++++++++++++++++++++++++++++++
>  include/linux/platform_data/edma.h |    1 +
>  2 files changed, 60 insertions(+)
> 
> diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c
> index 9823b79..1c2fb15 100644
> --- a/arch/arm/common/edma.c
> +++ b/arch/arm/common/edma.c
> @@ -1410,6 +1410,52 @@ static int edma_of_read_u32_to_s16_array(const struct device_node *np,
>  	return 0;
>  }
>  
> +static int edma_xbar_event_map(struct device *dev,
> +			       struct device_node *node,
> +			       struct edma_soc_info *pdata, int len)
> +{
> +	int ret = 0;
> +	int i;
> +	struct resource res;
> +	void *xbar;

void __iomem *xbar;

> +	const s16 (*xbar_chans)[2];
> +	u32 shift, offset, mux;
> +
> +	xbar_chans = devm_kzalloc(dev,
> +				  len/sizeof(s16) + 2*sizeof(s16),
> +				  GFP_KERNEL);
> +	if (!xbar_chans)
> +		return -ENOMEM;
> +
> +	ret = of_address_to_resource(node, 1, &res);
> +	if (ret)
> +		return -EIO;
> +
> +	xbar = devm_ioremap(dev, res.start, resource_size(&res));
> +	if (!xbar)
> +		return -ENOMEM;
> +
> +	ret = edma_of_read_u32_to_s16_array(node,
> +					    "ti,edma-xbar-event-map",
> +					    (s16 *)xbar_chans,
> +					    len/sizeof(u32));
> +	if (ret)
> +		return -EIO;
> +
> +	for (i = 0; xbar_chans[i][0] != -1; i++) {
> +		shift = (xbar_chans[i][1] & 0x03) << 3;
> +		offset = xbar_chans[i][1] & 0xfffffffc;
> +		mux = readl((void *)((u32)xbar + offset));

Please drop unnecessary casting. Simply:

	mux = readl(xbar + offset);

> +		mux &= ~(0xff << shift);
> +		mux |= xbar_chans[i][0] << shift;
> +		writel(mux, (void *)((u32)xbar + offset));

Fix the writel likewise.

> +	}
> +
> +	pdata->xbar_chans = xbar_chans;
> +
> +	return 0;
> +}
> +
>  static int edma_of_parse_dt(struct device *dev,
>  			    struct device_node *node,
>  			    struct edma_soc_info *pdata)
> @@ -1470,6 +1516,9 @@ static int edma_of_parse_dt(struct device *dev,
>  
>  	pdata->default_queue = 0;
>  
> +	prop = of_find_property(node, "ti,edma-xbar-event-map", &sz);
> +	if (prop)
> +		ret = edma_xbar_event_map(dev, node, pdata, sz);
>  
>  	return ret;
>  }
> @@ -1489,6 +1538,7 @@ static int edma_probe(struct platform_device *pdev)
>  	int			status = -1;
>  	const s16		(*rsv_chans)[2];
>  	const s16		(*rsv_slots)[2];
> +	const s16		(*xbar_chans)[2];
>  	int			irq[EDMA_MAX_CC] = {0, 0};
>  	int			err_irq[EDMA_MAX_CC] = {0, 0};
>  	struct resource		*r[EDMA_MAX_CC] = {NULL, NULL};
> @@ -1617,6 +1667,15 @@ static int edma_probe(struct platform_device *pdev)
>  			}
>  		}
>  
> +		/* Clear the xbar mapped channels in unused list */
> +		xbar_chans = info[j]->xbar_chans;
> +		if (xbar_chans) {
> +			for (i = 0; xbar_chans[i][1] != -1; i++) {
> +				off = xbar_chans[i][1];
> +				clear_bits(off, 1,
> +					edma_cc[j]->edma_unused);

Please fix the alignment here.

Thanks,
Sekhar
Joel A Fernandes June 20, 2013, 12:36 a.m. UTC | #2
Hi Sekhar,
Thanks for the feedback.

On Tue, Jun 18, 2013 at 5:19 AM, Sekhar Nori <nsekhar@ti.com> wrote:
> On 6/18/2013 12:08 PM, Joel A Fernandes wrote:
>> From: Matt Porter <mporter@ti.com>
>>
>> Changes by Joel:
>> * Split EDMA xbar support out of original EDMA DT parsing patch
>> to keep it easier for review.
>> * Rewrite shift and offset calculation.
>>
>> Suggested-by: Sekhar Nori <nsekhar@ti.com>
>> Suggested by: Andy Shevchenko <andy.shevchenko@gmail.com>
>> Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
>>
>> Reference:
>> [1] https://patchwork.kernel.org/patch/2226991/
>> ---
>>  arch/arm/common/edma.c             |   59 ++++++++++++++++++++++++++++++++++++
>>  include/linux/platform_data/edma.h |    1 +
>>  2 files changed, 60 insertions(+)
>>
>> diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c
>> index 9823b79..1c2fb15 100644
>> --- a/arch/arm/common/edma.c
>> +++ b/arch/arm/common/edma.c
>> @@ -1410,6 +1410,52 @@ static int edma_of_read_u32_to_s16_array(const struct device_node *np,
>>       return 0;
>>  }
>>
>> +static int edma_xbar_event_map(struct device *dev,
>> +                            struct device_node *node,
>> +                            struct edma_soc_info *pdata, int len)
>> +{
>> +     int ret = 0;
>> +     int i;
>> +     struct resource res;
>> +     void *xbar;
>
> void __iomem *xbar;

OK.

>> +     const s16 (*xbar_chans)[2];
>> +     u32 shift, offset, mux;
>> +
>> +     xbar_chans = devm_kzalloc(dev,
>> +                               len/sizeof(s16) + 2*sizeof(s16),
>> +                               GFP_KERNEL);
>> +     if (!xbar_chans)
>> +             return -ENOMEM;
>> +
>> +     ret = of_address_to_resource(node, 1, &res);
>> +     if (ret)
>> +             return -EIO;
>> +
>> +     xbar = devm_ioremap(dev, res.start, resource_size(&res));
>> +     if (!xbar)
>> +             return -ENOMEM;
>> +
>> +     ret = edma_of_read_u32_to_s16_array(node,
>> +                                         "ti,edma-xbar-event-map",
>> +                                         (s16 *)xbar_chans,
>> +                                         len/sizeof(u32));
>> +     if (ret)
>> +             return -EIO;
>> +
>> +     for (i = 0; xbar_chans[i][0] != -1; i++) {
>> +             shift = (xbar_chans[i][1] & 0x03) << 3;
>> +             offset = xbar_chans[i][1] & 0xfffffffc;
>> +             mux = readl((void *)((u32)xbar + offset));
>
> Please drop unnecessary casting. Simply:

Done.

>
>         mux = readl(xbar + offset);
>
>> +             mux &= ~(0xff << shift);
>> +             mux |= xbar_chans[i][0] << shift;
>> +             writel(mux, (void *)((u32)xbar + offset));
>
> Fix the writel likewise.

Done.


>>               }
>>
>> +             /* Clear the xbar mapped channels in unused list */
>> +             xbar_chans = info[j]->xbar_chans;
>> +             if (xbar_chans) {
>> +                     for (i = 0; xbar_chans[i][1] != -1; i++) {
>> +                             off = xbar_chans[i][1];
>> +                             clear_bits(off, 1,
>> +                                     edma_cc[j]->edma_unused);
>
> Please fix the alignment here.

I noticed the alignment was off in a few other places in that driver.
Fixed those up too.

Thanks,
Joel
Sekhar Nori June 20, 2013, 4:49 a.m. UTC | #3
On 6/20/2013 6:06 AM, Joel A Fernandes wrote:

>>> +             /* Clear the xbar mapped channels in unused list */
>>> +             xbar_chans = info[j]->xbar_chans;
>>> +             if (xbar_chans) {
>>> +                     for (i = 0; xbar_chans[i][1] != -1; i++) {
>>> +                             off = xbar_chans[i][1];
>>> +                             clear_bits(off, 1,
>>> +                                     edma_cc[j]->edma_unused);
>>
>> Please fix the alignment here.
> 
> I noticed the alignment was off in a few other places in that driver.
> Fixed those up too.

If you do, please make it a separate (pre)patch.

Thanks,
Sekhar
diff mbox

Patch

diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c
index 9823b79..1c2fb15 100644
--- a/arch/arm/common/edma.c
+++ b/arch/arm/common/edma.c
@@ -1410,6 +1410,52 @@  static int edma_of_read_u32_to_s16_array(const struct device_node *np,
 	return 0;
 }
 
+static int edma_xbar_event_map(struct device *dev,
+			       struct device_node *node,
+			       struct edma_soc_info *pdata, int len)
+{
+	int ret = 0;
+	int i;
+	struct resource res;
+	void *xbar;
+	const s16 (*xbar_chans)[2];
+	u32 shift, offset, mux;
+
+	xbar_chans = devm_kzalloc(dev,
+				  len/sizeof(s16) + 2*sizeof(s16),
+				  GFP_KERNEL);
+	if (!xbar_chans)
+		return -ENOMEM;
+
+	ret = of_address_to_resource(node, 1, &res);
+	if (ret)
+		return -EIO;
+
+	xbar = devm_ioremap(dev, res.start, resource_size(&res));
+	if (!xbar)
+		return -ENOMEM;
+
+	ret = edma_of_read_u32_to_s16_array(node,
+					    "ti,edma-xbar-event-map",
+					    (s16 *)xbar_chans,
+					    len/sizeof(u32));
+	if (ret)
+		return -EIO;
+
+	for (i = 0; xbar_chans[i][0] != -1; i++) {
+		shift = (xbar_chans[i][1] & 0x03) << 3;
+		offset = xbar_chans[i][1] & 0xfffffffc;
+		mux = readl((void *)((u32)xbar + offset));
+		mux &= ~(0xff << shift);
+		mux |= xbar_chans[i][0] << shift;
+		writel(mux, (void *)((u32)xbar + offset));
+	}
+
+	pdata->xbar_chans = xbar_chans;
+
+	return 0;
+}
+
 static int edma_of_parse_dt(struct device *dev,
 			    struct device_node *node,
 			    struct edma_soc_info *pdata)
@@ -1470,6 +1516,9 @@  static int edma_of_parse_dt(struct device *dev,
 
 	pdata->default_queue = 0;
 
+	prop = of_find_property(node, "ti,edma-xbar-event-map", &sz);
+	if (prop)
+		ret = edma_xbar_event_map(dev, node, pdata, sz);
 
 	return ret;
 }
@@ -1489,6 +1538,7 @@  static int edma_probe(struct platform_device *pdev)
 	int			status = -1;
 	const s16		(*rsv_chans)[2];
 	const s16		(*rsv_slots)[2];
+	const s16		(*xbar_chans)[2];
 	int			irq[EDMA_MAX_CC] = {0, 0};
 	int			err_irq[EDMA_MAX_CC] = {0, 0};
 	struct resource		*r[EDMA_MAX_CC] = {NULL, NULL};
@@ -1617,6 +1667,15 @@  static int edma_probe(struct platform_device *pdev)
 			}
 		}
 
+		/* Clear the xbar mapped channels in unused list */
+		xbar_chans = info[j]->xbar_chans;
+		if (xbar_chans) {
+			for (i = 0; xbar_chans[i][1] != -1; i++) {
+				off = xbar_chans[i][1];
+				clear_bits(off, 1,
+					edma_cc[j]->edma_unused);
+			}
+		}
 
 		if (node)
 			irq[j] = irq_of_parse_and_map(node, 0);
diff --git a/include/linux/platform_data/edma.h b/include/linux/platform_data/edma.h
index 317f2be..57300fd 100644
--- a/include/linux/platform_data/edma.h
+++ b/include/linux/platform_data/edma.h
@@ -177,6 +177,7 @@  struct edma_soc_info {
 
 	s8	(*queue_tc_mapping)[2];
 	s8	(*queue_priority_mapping)[2];
+	const s16	(*xbar_chans)[2];
 };
 
 #endif