diff mbox

[V3,2/6] dmaengine: add interrupt check for GPMI controller

Message ID 1301554968-29066-1-git-send-email-b32955@freescale.com
State New, archived
Headers show

Commit Message

Huang Shijie March 31, 2011, 7:02 a.m. UTC
The GPMI may have many DMA channels, such as the imx23 has
four DMA channels. All these DMA channels share the same interrupt.
Add the interrupt check for the GPMI, only the first DMA channel will
register the irq.

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 drivers/dma/mxs-dma.c |   36 ++++++++++++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 4 deletions(-)

Comments

Lothar Waßmann March 31, 2011, 8:02 a.m. UTC | #1
Hi,

Huang Shijie writes:
> The GPMI may have many DMA channels, such as the imx23 has
> four DMA channels. All these DMA channels share the same interrupt.
> Add the interrupt check for the GPMI, only the first DMA channel will
> register the irq.
> 
> Signed-off-by: Huang Shijie <b32955@freescale.com>
> ---
>  drivers/dma/mxs-dma.c |   36 ++++++++++++++++++++++++++++++++----
>  1 files changed, 32 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> index 88aad4f..db36bf1 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -26,6 +26,8 @@
>  #include <asm/irq.h>
>  #include <mach/mxs.h>
>  #include <mach/dma.h>
> +#include <mach/mx23.h>
> +#include <mach/mx28.h>
>  #include <mach/common.h>
>  
>  /*
> @@ -306,6 +308,30 @@ static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id)
>  	return IRQ_HANDLED;
>  }
>  
> +/* The GPMI has several DMA channels, only the first can register the irq. */
> +static bool irq_check(struct mxs_dma_chan *mxs_chan)
> +{
> +	int irq_num = mxs_chan->chan_irq;
> +
> +#ifdef CONFIG_SOC_IMX23
> +	if (cpu_is_mx23() && irq_num == MX23_INT_GPMI_DMA) {
> +		if (mxs_chan->chan.chan_id == MX23_DMA_GPMI0)
> +			return true;
> +		else
> +			return false;
> +	}
> +#endif
> +#ifdef CONFIG_SOC_IMX28
> +	if (cpu_is_mx28() && irq_num == MX28_INT_GPMI_DMA) {
> +		if (mxs_chan->chan.chan_id == MX28_DMA_GPMI0)
> +			return true;
> +		else
> +			return false;
> +	}
> +#endif
> +	return true;
> +}
>
You should make the distinction based on the platform_id, which would
save you the ugly ifdef's and cpu_is_... macros.


Lothar Waßmann
Lothar Waßmann March 31, 2011, 8:50 a.m. UTC | #2
Hi,

Huang Shijie writes:
> Hi:
> > Hi,
> >
> > Huang Shijie writes:
> >> The GPMI may have many DMA channels, such as the imx23 has
> >> four DMA channels. All these DMA channels share the same interrupt.
> >> Add the interrupt check for the GPMI, only the first DMA channel will
> >> register the irq.
> >>
> >> Signed-off-by: Huang Shijie<b32955@freescale.com>
> >> ---
> >>   drivers/dma/mxs-dma.c |   36 ++++++++++++++++++++++++++++++++----
> >>   1 files changed, 32 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> >> index 88aad4f..db36bf1 100644
> >> --- a/drivers/dma/mxs-dma.c
> >> +++ b/drivers/dma/mxs-dma.c
> >> @@ -26,6 +26,8 @@
> >>   #include<asm/irq.h>
> >>   #include<mach/mxs.h>
> >>   #include<mach/dma.h>
> >> +#include<mach/mx23.h>
> >> +#include<mach/mx28.h>
> >>   #include<mach/common.h>
> >>
> >>   /*
> >> @@ -306,6 +308,30 @@ static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id)
> >>   	return IRQ_HANDLED;
> >>   }
> >>
> >> +/* The GPMI has several DMA channels, only the first can register the irq. */
> >> +static bool irq_check(struct mxs_dma_chan *mxs_chan)
> >> +{
> >> +	int irq_num = mxs_chan->chan_irq;
> >> +
> >> +#ifdef CONFIG_SOC_IMX23
> >> +	if (cpu_is_mx23()&&  irq_num == MX23_INT_GPMI_DMA) {
> >> +		if (mxs_chan->chan.chan_id == MX23_DMA_GPMI0)
> >> +			return true;
> >> +		else
> >> +			return false;
> >> +	}
> >> +#endif
> >> +#ifdef CONFIG_SOC_IMX28
> >> +	if (cpu_is_mx28()&&  irq_num == MX28_INT_GPMI_DMA) {
> >> +		if (mxs_chan->chan.chan_id == MX28_DMA_GPMI0)
> >> +			return true;
> >> +		else
> >> +			return false;
> >> +	}
> >> +#endif
> >> +	return true;
> >> +}
> >>
> > You should make the distinction based on the platform_id, which would
> > save you the ugly ifdef's and cpu_is_... macros.
> >
> >
> This in the DMA driver.
> Do you want me to change the DMA driver to add the platform_id?
> The DMA driver has already used the cpu_is_xx() macros.
>
The mxs-dma driver is already using platform ids!


Lothar Waßmann
Huang Shijie March 31, 2011, 8:50 a.m. UTC | #3
Hi:
> Hi,
>
> Huang Shijie writes:
>> The GPMI may have many DMA channels, such as the imx23 has
>> four DMA channels. All these DMA channels share the same interrupt.
>> Add the interrupt check for the GPMI, only the first DMA channel will
>> register the irq.
>>
>> Signed-off-by: Huang Shijie<b32955@freescale.com>
>> ---
>>   drivers/dma/mxs-dma.c |   36 ++++++++++++++++++++++++++++++++----
>>   1 files changed, 32 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
>> index 88aad4f..db36bf1 100644
>> --- a/drivers/dma/mxs-dma.c
>> +++ b/drivers/dma/mxs-dma.c
>> @@ -26,6 +26,8 @@
>>   #include<asm/irq.h>
>>   #include<mach/mxs.h>
>>   #include<mach/dma.h>
>> +#include<mach/mx23.h>
>> +#include<mach/mx28.h>
>>   #include<mach/common.h>
>>
>>   /*
>> @@ -306,6 +308,30 @@ static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id)
>>   	return IRQ_HANDLED;
>>   }
>>
>> +/* The GPMI has several DMA channels, only the first can register the irq. */
>> +static bool irq_check(struct mxs_dma_chan *mxs_chan)
>> +{
>> +	int irq_num = mxs_chan->chan_irq;
>> +
>> +#ifdef CONFIG_SOC_IMX23
>> +	if (cpu_is_mx23()&&  irq_num == MX23_INT_GPMI_DMA) {
>> +		if (mxs_chan->chan.chan_id == MX23_DMA_GPMI0)
>> +			return true;
>> +		else
>> +			return false;
>> +	}
>> +#endif
>> +#ifdef CONFIG_SOC_IMX28
>> +	if (cpu_is_mx28()&&  irq_num == MX28_INT_GPMI_DMA) {
>> +		if (mxs_chan->chan.chan_id == MX28_DMA_GPMI0)
>> +			return true;
>> +		else
>> +			return false;
>> +	}
>> +#endif
>> +	return true;
>> +}
>>
> You should make the distinction based on the platform_id, which would
> save you the ugly ifdef's and cpu_is_... macros.
>
>
This in the DMA driver.
Do you want me to change the DMA driver to add the platform_id?
The DMA driver has already used the cpu_is_xx() macros.

Best Regards
Huang Shijie

> Lothar Waßmann
Huang Shijie March 31, 2011, 9:08 a.m. UTC | #4
Hi,
> Hi,
>
> Huang Shijie writes:
>> Hi:
>>> Hi,
>>>
>>> Huang Shijie writes:
>>>> The GPMI may have many DMA channels, such as the imx23 has
>>>> four DMA channels. All these DMA channels share the same interrupt.
>>>> Add the interrupt check for the GPMI, only the first DMA channel will
>>>> register the irq.
>>>>
>>>> Signed-off-by: Huang Shijie<b32955@freescale.com>
>>>> ---
>>>>    drivers/dma/mxs-dma.c |   36 ++++++++++++++++++++++++++++++++----
>>>>    1 files changed, 32 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
>>>> index 88aad4f..db36bf1 100644
>>>> --- a/drivers/dma/mxs-dma.c
>>>> +++ b/drivers/dma/mxs-dma.c
>>>> @@ -26,6 +26,8 @@
>>>>    #include<asm/irq.h>
>>>>    #include<mach/mxs.h>
>>>>    #include<mach/dma.h>
>>>> +#include<mach/mx23.h>
>>>> +#include<mach/mx28.h>
>>>>    #include<mach/common.h>
>>>>
>>>>    /*
>>>> @@ -306,6 +308,30 @@ static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id)
>>>>    	return IRQ_HANDLED;
>>>>    }
>>>>
>>>> +/* The GPMI has several DMA channels, only the first can register the irq. */
>>>> +static bool irq_check(struct mxs_dma_chan *mxs_chan)
>>>> +{
>>>> +	int irq_num = mxs_chan->chan_irq;
>>>> +
>>>> +#ifdef CONFIG_SOC_IMX23
>>>> +	if (cpu_is_mx23()&&   irq_num == MX23_INT_GPMI_DMA) {
>>>> +		if (mxs_chan->chan.chan_id == MX23_DMA_GPMI0)
>>>> +			return true;
>>>> +		else
>>>> +			return false;
>>>> +	}
>>>> +#endif
>>>> +#ifdef CONFIG_SOC_IMX28
>>>> +	if (cpu_is_mx28()&&   irq_num == MX28_INT_GPMI_DMA) {
>>>> +		if (mxs_chan->chan.chan_id == MX28_DMA_GPMI0)
>>>> +			return true;
>>>> +		else
>>>> +			return false;
>>>> +	}
>>>> +#endif
>>>> +	return true;
>>>> +}
>>>>
>>> You should make the distinction based on the platform_id, which would
>>> save you the ugly ifdef's and cpu_is_... macros.
>>>
>>>
>> This in the DMA driver.
>> Do you want me to change the DMA driver to add the platform_id?
>> The DMA driver has already used the cpu_is_xx() macros.
>>
> The mxs-dma driver is already using platform ids!
>
>
Do you mean the mxd_dma_type[] ?

How can i distinction the imx23 and imx28 with it ?
It seems can not be used to do the work.

thanks.

Huang Shijie


> Lothar Waßmann
Lothar Waßmann March 31, 2011, 9:34 a.m. UTC | #5
Hi,

Huang Shijie writes:
> Hi,
> > Hi,
> >
> > Huang Shijie writes:
> >> Hi:
> >>> Hi,
> >>>
> >>> Huang Shijie writes:
> >>>> The GPMI may have many DMA channels, such as the imx23 has
> >>>> four DMA channels. All these DMA channels share the same interrupt.
> >>>> Add the interrupt check for the GPMI, only the first DMA channel will
> >>>> register the irq.
> >>>>
> >>>> Signed-off-by: Huang Shijie<b32955@freescale.com>
> >>>> ---
> >>>>    drivers/dma/mxs-dma.c |   36 ++++++++++++++++++++++++++++++++----
> >>>>    1 files changed, 32 insertions(+), 4 deletions(-)
> >>>>
> >>>> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> >>>> index 88aad4f..db36bf1 100644
> >>>> --- a/drivers/dma/mxs-dma.c
> >>>> +++ b/drivers/dma/mxs-dma.c
> >>>> @@ -26,6 +26,8 @@
> >>>>    #include<asm/irq.h>
> >>>>    #include<mach/mxs.h>
> >>>>    #include<mach/dma.h>
> >>>> +#include<mach/mx23.h>
> >>>> +#include<mach/mx28.h>
> >>>>    #include<mach/common.h>
> >>>>
> >>>>    /*
> >>>> @@ -306,6 +308,30 @@ static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id)
> >>>>    	return IRQ_HANDLED;
> >>>>    }
> >>>>
> >>>> +/* The GPMI has several DMA channels, only the first can register the irq. */
> >>>> +static bool irq_check(struct mxs_dma_chan *mxs_chan)
> >>>> +{
> >>>> +	int irq_num = mxs_chan->chan_irq;
> >>>> +
> >>>> +#ifdef CONFIG_SOC_IMX23
> >>>> +	if (cpu_is_mx23()&&   irq_num == MX23_INT_GPMI_DMA) {
> >>>> +		if (mxs_chan->chan.chan_id == MX23_DMA_GPMI0)
> >>>> +			return true;
> >>>> +		else
> >>>> +			return false;
> >>>> +	}
> >>>> +#endif
> >>>> +#ifdef CONFIG_SOC_IMX28
> >>>> +	if (cpu_is_mx28()&&   irq_num == MX28_INT_GPMI_DMA) {
> >>>> +		if (mxs_chan->chan.chan_id == MX28_DMA_GPMI0)
> >>>> +			return true;
> >>>> +		else
> >>>> +			return false;
> >>>> +	}
> >>>> +#endif
> >>>> +	return true;
> >>>> +}
> >>>>
> >>> You should make the distinction based on the platform_id, which would
> >>> save you the ugly ifdef's and cpu_is_... macros.
> >>>
> >>>
> >> This in the DMA driver.
> >> Do you want me to change the DMA driver to add the platform_id?
> >> The DMA driver has already used the cpu_is_xx() macros.
> >>
> > The mxs-dma driver is already using platform ids!
> >
> >
> Do you mean the mxd_dma_type[] ?
> 
> How can i distinction the imx23 and imx28 with it ?
> It seems can not be used to do the work.
> 
It should be extended to make this distinction possible.


Lothar Waßmann
Shawn Guo April 1, 2011, 3:47 a.m. UTC | #6
On Thu, Mar 31, 2011 at 05:08:54PM +0800, Huang Shijie wrote:
[...]
> >>>You should make the distinction based on the platform_id, which would
> >>>save you the ugly ifdef's and cpu_is_... macros.
> >>>
> >>>
> >>This in the DMA driver.
> >>Do you want me to change the DMA driver to add the platform_id?
> >>The DMA driver has already used the cpu_is_xx() macros.
> >>
> >The mxs-dma driver is already using platform ids!
> >
> >
> Do you mean the mxd_dma_type[] ?
> 
> How can i distinction the imx23 and imx28 with it ?
> It seems can not be used to do the work.
> 
You can drop the dmaengine patch from your gpmi series.  I will find
some time to fix this together with removing cpu_is_xx() and inclusion
of mxs.h, to get it prepared for i.mx50 aphb-dma support.
Huang Shijie April 1, 2011, 4:36 a.m. UTC | #7
hi:
> On Thu, Mar 31, 2011 at 05:08:54PM +0800, Huang Shijie wrote:
> [...]
>>>>> You should make the distinction based on the platform_id, which would
>>>>> save you the ugly ifdef's and cpu_is_... macros.
>>>>>
>>>>>
>>>> This in the DMA driver.
>>>> Do you want me to change the DMA driver to add the platform_id?
>>>> The DMA driver has already used the cpu_is_xx() macros.
>>>>
>>> The mxs-dma driver is already using platform ids!
>>>
>>>
>> Do you mean the mxd_dma_type[] ?
>>
>> How can i distinction the imx23 and imx28 with it ?
>> It seems can not be used to do the work.
>>
> You can drop the dmaengine patch from your gpmi series.  I will find
> some time to fix this together with removing cpu_is_xx() and inclusion
> of mxs.h, to get it prepared for i.mx50 aphb-dma support.
>
ok, thanks.

Huang Shijie
diff mbox

Patch

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 88aad4f..db36bf1 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -26,6 +26,8 @@ 
 #include <asm/irq.h>
 #include <mach/mxs.h>
 #include <mach/dma.h>
+#include <mach/mx23.h>
+#include <mach/mx28.h>
 #include <mach/common.h>
 
 /*
@@ -306,6 +308,30 @@  static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+/* The GPMI has several DMA channels, only the first can register the irq. */
+static bool irq_check(struct mxs_dma_chan *mxs_chan)
+{
+	int irq_num = mxs_chan->chan_irq;
+
+#ifdef CONFIG_SOC_IMX23
+	if (cpu_is_mx23() && irq_num == MX23_INT_GPMI_DMA) {
+		if (mxs_chan->chan.chan_id == MX23_DMA_GPMI0)
+			return true;
+		else
+			return false;
+	}
+#endif
+#ifdef CONFIG_SOC_IMX28
+	if (cpu_is_mx28() && irq_num == MX28_INT_GPMI_DMA) {
+		if (mxs_chan->chan.chan_id == MX28_DMA_GPMI0)
+			return true;
+		else
+			return false;
+	}
+#endif
+	return true;
+}
+
 static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)
 {
 	struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan);
@@ -327,10 +353,12 @@  static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)
 
 	memset(mxs_chan->ccw, 0, PAGE_SIZE);
 
-	ret = request_irq(mxs_chan->chan_irq, mxs_dma_int_handler,
-				0, "mxs-dma", mxs_dma);
-	if (ret)
-		goto err_irq;
+	if (irq_check(mxs_chan)) {
+		ret = request_irq(mxs_chan->chan_irq, mxs_dma_int_handler,
+					0, "mxs-dma", mxs_dma);
+		if (ret)
+			goto err_irq;
+	}
 
 	ret = clk_enable(mxs_dma->clk);
 	if (ret)