Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 2/2] USB: at91: using USBA_NR_DMAS for DMA channels

1 view
Skip to first unread message

Bo Shen

unread,
Jan 16, 2014, 10:10:01 PM1/16/14
to
When the SoC is earlier than sama5d3 SoC, which have the same number
endpoints and DMAs. However for sama5d3 SoC, it has different number
for endpoints and DMAs. So, define USBA_NR_DMAs for DMA channels

Signed-off-by: Bo Shen <voice...@atmel.com>
---

drivers/usb/gadget/atmel_usba_udc.c | 2 +-
drivers/usb/gadget/atmel_usba_udc.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 7e67a81..5cded1c 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1661,7 +1661,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
if (dma_status) {
int i;

- for (i = 1; i < USBA_NR_ENDPOINTS; i++)
+ for (i = 1; i < USBA_NR_DMAS; i++)
if (dma_status & (1 << i))
usba_dma_irq(udc, &udc->usba_ep[i]);
}
diff --git a/drivers/usb/gadget/atmel_usba_udc.h b/drivers/usb/gadget/atmel_usba_udc.h
index 2922db5..a70706e 100644
--- a/drivers/usb/gadget/atmel_usba_udc.h
+++ b/drivers/usb/gadget/atmel_usba_udc.h
@@ -210,7 +210,7 @@
#define USBA_FIFO_BASE(x) ((x) << 16)

/* Synth parameters */
-#define USBA_NR_ENDPOINTS 7
+#define USBA_NR_DMAS 7

#define EP0_FIFO_SIZE 64
#define EP0_EPT_SIZE USBA_EPT_SIZE_64
--
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Bo Shen

unread,
Jan 16, 2014, 10:10:01 PM1/16/14
to
In sama5d3 SoC, there are 16 endpoints. As the USBA_NR_ENDPOINTS
is only 7. So, fix it for sama5d3 SoC using the udc->num_ep.

Signed-off-by: Bo Shen <voice...@atmel.com>
---

drivers/usb/gadget/atmel_usba_udc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 2cb52e0..7e67a81 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1670,7 +1670,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
if (ep_status) {
int i;

- for (i = 0; i < USBA_NR_ENDPOINTS; i++)
+ for (i = 0; i < udc->num_ep; i++)
if (ep_status & (1 << i)) {
if (ep_is_control(&udc->usba_ep[i]))
usba_control_irq(udc, &udc->usba_ep[i]);

Nicolas Ferre

unread,
Jan 17, 2014, 4:30:01 AM1/17/14
to
On 17/01/2014 03:59, Bo Shen :
> When the SoC is earlier than sama5d3 SoC, which have the same number
> endpoints and DMAs. However for sama5d3 SoC, it has different number
> for endpoints and DMAs. So, define USBA_NR_DMAs for DMA channels
>
> Signed-off-by: Bo Shen <voice...@atmel.com>

Acked-by: Nicolas Ferre <nicola...@atmel.com>
Nicolas Ferre

Nicolas Ferre

unread,
Jan 17, 2014, 4:30:02 AM1/17/14
to
On 17/01/2014 03:59, Bo Shen :
> In sama5d3 SoC, there are 16 endpoints. As the USBA_NR_ENDPOINTS
> is only 7. So, fix it for sama5d3 SoC using the udc->num_ep.
>
> Signed-off-by: Bo Shen <voice...@atmel.com>

Acked-by: Nicolas Ferre <nicola...@atmel.com>

> ---
>
> drivers/usb/gadget/atmel_usba_udc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
> index 2cb52e0..7e67a81 100644
> --- a/drivers/usb/gadget/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/atmel_usba_udc.c
> @@ -1670,7 +1670,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
> if (ep_status) {
> int i;
>
> - for (i = 0; i < USBA_NR_ENDPOINTS; i++)
> + for (i = 0; i < udc->num_ep; i++)
> if (ep_status & (1 << i)) {
> if (ep_is_control(&udc->usba_ep[i]))
> usba_control_irq(udc, &udc->usba_ep[i]);
>


--
Nicolas Ferre

Jean-Christophe PLAGNIOL-VILLARD

unread,
Jan 18, 2014, 12:30:02 AM1/18/14
to
On 10:59 Fri 17 Jan , Bo Shen wrote:
> In sama5d3 SoC, there are 16 endpoints. As the USBA_NR_ENDPOINTS
> is only 7. So, fix it for sama5d3 SoC using the udc->num_ep.
>
> Signed-off-by: Bo Shen <voice...@atmel.com>
> ---
>
> drivers/usb/gadget/atmel_usba_udc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
> index 2cb52e0..7e67a81 100644
> --- a/drivers/usb/gadget/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/atmel_usba_udc.c
> @@ -1670,7 +1670,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
> if (ep_status) {
> int i;
>
> - for (i = 0; i < USBA_NR_ENDPOINTS; i++)
> + for (i = 0; i < udc->num_ep; i++)

no the limit need to specified in the driver as a checkpoint by the compatible
or platform driver id

Best Regards,
J.

Bo Shen

unread,
Jan 19, 2014, 10:40:02 PM1/19/14
to
Hi J,

On 01/18/2014 01:20 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:59 Fri 17 Jan , Bo Shen wrote:
>> In sama5d3 SoC, there are 16 endpoints. As the USBA_NR_ENDPOINTS
>> is only 7. So, fix it for sama5d3 SoC using the udc->num_ep.
>>
>> Signed-off-by: Bo Shen <voice...@atmel.com>
>> ---
>>
>> drivers/usb/gadget/atmel_usba_udc.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
>> index 2cb52e0..7e67a81 100644
>> --- a/drivers/usb/gadget/atmel_usba_udc.c
>> +++ b/drivers/usb/gadget/atmel_usba_udc.c
>> @@ -1670,7 +1670,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
>> if (ep_status) {
>> int i;
>>
>> - for (i = 0; i < USBA_NR_ENDPOINTS; i++)
>> + for (i = 0; i < udc->num_ep; i++)
>
> no the limit need to specified in the driver as a checkpoint by the compatible
> or platform driver id

You mean, we should not trust the data passed from dt node or platform
data? Or do you think we should do double confirm?

> Best Regards,
> J.
>> if (ep_status & (1 << i)) {
>> if (ep_is_control(&udc->usba_ep[i]))
>> usba_control_irq(udc, &udc->usba_ep[i]);
>> --
>> 1.8.5.2
>>

Best Regards,
Bo Shen

Jean-Christophe PLAGNIOL-VILLARD

unread,
Jan 21, 2014, 1:30:01 AM1/21/14
to
On 11:39 Mon 20 Jan , Bo Shen wrote:
> Hi J,
>
> On 01/18/2014 01:20 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> >On 10:59 Fri 17 Jan , Bo Shen wrote:
> >>In sama5d3 SoC, there are 16 endpoints. As the USBA_NR_ENDPOINTS
> >>is only 7. So, fix it for sama5d3 SoC using the udc->num_ep.
> >>
> >>Signed-off-by: Bo Shen <voice...@atmel.com>
> >>---
> >>
> >> drivers/usb/gadget/atmel_usba_udc.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >>diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
> >>index 2cb52e0..7e67a81 100644
> >>--- a/drivers/usb/gadget/atmel_usba_udc.c
> >>+++ b/drivers/usb/gadget/atmel_usba_udc.c
> >>@@ -1670,7 +1670,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
> >> if (ep_status) {
> >> int i;
> >>
> >>- for (i = 0; i < USBA_NR_ENDPOINTS; i++)
> >>+ for (i = 0; i < udc->num_ep; i++)
> >
> >no the limit need to specified in the driver as a checkpoint by the compatible
> >or platform driver id
>
> You mean, we should not trust the data passed from dt node or
> platform data? Or do you think we should do double confirm?

no base on the driver name or the compatible you will known the MAX EP

not based on the dt ep description

as we do on pinctrl-at91

Bo Shen

unread,
Jan 21, 2014, 3:20:01 AM1/21/14
to
Hi J,
I am sorry, I am not fully get it after reading the code of
pinctrl-at91.c, can you give the example code in pinctrl-at91.c?

Btw, the udc->num_ep is get from the following code.
for dt
--->8---
while ((pp = of_get_next_child(np, pp)))
udc->num_ep++;
---<8---

for non-dt
--->8---
udc->num_ep = pdata->num_ep;
---8<---

Nicolas Ferre

unread,
Jan 21, 2014, 4:10:01 AM1/21/14
to
On 21/01/2014 09:12, Bo Shen :
It seems to me pretty valid to use num_ep in this driver and not have to
rely on another compatibility string just for this.
The information is here, it is retrieved pretty cleanly so I vote for a
simple use of it: if we introduce another information we will have to
double check the cross errors that would happen...

Bye,

>>>>> if (ep_status & (1 << i)) {
>>>>> if (ep_is_control(&udc->usba_ep[i]))
>>>>> usba_control_irq(udc, &udc->usba_ep[i]);
>>>>> --
>>>>> 1.8.5.2
>>>>>
>>>
>>> Best Regards,
>>> Bo Shen
>
> Best Regards,
> Bo Shen
>


--
Nicolas Ferre

Jean-Christophe PLAGNIOL-VILLARD

unread,
Feb 7, 2014, 4:20:02 AM2/7/14
to
here is the key point you describe the HW

so choose detect the IP version and then check we do not describe too many EP
or you prove the correct compatible so we known this not the same IP
and we can check the DT information

Best Regards,
J.

Felipe Balbi

unread,
Feb 18, 2014, 11:30:04 AM2/18/14
to
what's the difference ? You just renamed this macro. Also, please
clarify a bit your commit log.

--
balbi
signature.asc

Bo Shen

unread,
Feb 18, 2014, 8:20:01 PM2/18/14
to
Hi Felipe Balbi,
As commit message said, the SoC before sama5d3, the endpoint number is
the same as DMA channel number, so use endpoints definition for DMA
channel number, however after sama5d3, the endpoints is not the same as
DMA channel, so use DMA micro for DMA channels.

Best Regards,
Bo Shen

Felipe Balbi

unread,
Feb 18, 2014, 8:30:03 PM2/18/14
to
which means you're just renaming the macro for the sake of clarity.
That's fine, just needs to be clearer in commit message.

--
balbi
signature.asc

Bo Shen

unread,
Feb 18, 2014, 8:50:01 PM2/18/14
to
Thanks, I will send v2 to make the commit message more clearer.

Bo Shen

unread,
Feb 18, 2014, 9:10:03 PM2/18/14
to
The SoCs earlier than sama5d3, they have the same number endpoints
and DMA channels. In driver code, they use the same definition
USBA_NR_ENDPOINTS for both endpoints and dma channels. However,
in sama5d3, it has different number for endpoints and DMA channels.
So, define a new micro USBA_NR_DMAs for DMA channels. And the
USBA_NR_ENDPOINS is not used anymore, remove it at the same time.

Signed-off-by: Bo Shen <voice...@atmel.com>
---
Changes in v2:
- Make the commit message more clearer.

drivers/usb/gadget/atmel_usba_udc.c | 2 +-
drivers/usb/gadget/atmel_usba_udc.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 7e67a81..5cded1c 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1661,7 +1661,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
if (dma_status) {
int i;

- for (i = 1; i < USBA_NR_ENDPOINTS; i++)
+ for (i = 1; i < USBA_NR_DMAS; i++)
if (dma_status & (1 << i))
usba_dma_irq(udc, &udc->usba_ep[i]);
}
diff --git a/drivers/usb/gadget/atmel_usba_udc.h b/drivers/usb/gadget/atmel_usba_udc.h
index 2922db5..a70706e 100644
--- a/drivers/usb/gadget/atmel_usba_udc.h
+++ b/drivers/usb/gadget/atmel_usba_udc.h
@@ -210,7 +210,7 @@
#define USBA_FIFO_BASE(x) ((x) << 16)

/* Synth parameters */
-#define USBA_NR_ENDPOINTS 7
+#define USBA_NR_DMAS 7

#define EP0_FIFO_SIZE 64
#define EP0_EPT_SIZE USBA_EPT_SIZE_64
--
1.8.5.2

Bo Shen

unread,
Feb 18, 2014, 9:10:03 PM2/18/14
to
In sama5d3 SoC, there are 16 endpoints, which is different with
earlier SoCs (only have 7 endpoints). The USBA_NR_ENDPOINTS micro
is not suitable for sama5d3. So, get the endpoints number through
the udc->num_ep, which get from platform data for non-dt kernel,
or parse from dt node.

Signed-off-by: Bo Shen <voice...@atmel.com>
---
Changes in v2:
- Make the commit message more clearer.

drivers/usb/gadget/atmel_usba_udc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 2cb52e0..7e67a81 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1670,7 +1670,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
if (ep_status) {
int i;

- for (i = 0; i < USBA_NR_ENDPOINTS; i++)
+ for (i = 0; i < udc->num_ep; i++)
if (ep_status & (1 << i)) {
if (ep_is_control(&udc->usba_ep[i]))
usba_control_irq(udc, &udc->usba_ep[i]);

Nicolas Ferre

unread,
Feb 19, 2014, 3:50:02 AM2/19/14
to
On 19/02/2014 03:07, Bo Shen :
> The SoCs earlier than sama5d3, they have the same number endpoints
> and DMA channels. In driver code, they use the same definition
> USBA_NR_ENDPOINTS for both endpoints and dma channels. However,
> in sama5d3, it has different number for endpoints and DMA channels.
> So, define a new micro USBA_NR_DMAs for DMA channels. And the

s/micro/macro/

> USBA_NR_ENDPOINS is not used anymore, remove it at the same time.
>
> Signed-off-by: Bo Shen <voice...@atmel.com>

Acked-by: Nicolas Ferre <nicola...@atmel.com>
Nicolas Ferre

Nicolas Ferre

unread,
Feb 19, 2014, 3:50:02 AM2/19/14
to
On 19/02/2014 03:07, Bo Shen :
> In sama5d3 SoC, there are 16 endpoints, which is different with
> earlier SoCs (only have 7 endpoints). The USBA_NR_ENDPOINTS micro

you should read "macro".

> is not suitable for sama5d3. So, get the endpoints number through
> the udc->num_ep, which get from platform data for non-dt kernel,
> or parse from dt node.
>
> Signed-off-by: Bo Shen <voice...@atmel.com>

Acked-by: Nicolas Ferre <nicola...@atmel.com>

> ---
> Changes in v2:
> - Make the commit message more clearer.
>
> drivers/usb/gadget/atmel_usba_udc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
> index 2cb52e0..7e67a81 100644
> --- a/drivers/usb/gadget/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/atmel_usba_udc.c
> @@ -1670,7 +1670,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
> if (ep_status) {
> int i;
>
> - for (i = 0; i < USBA_NR_ENDPOINTS; i++)
> + for (i = 0; i < udc->num_ep; i++)
> if (ep_status & (1 << i)) {
> if (ep_is_control(&udc->usba_ep[i]))
> usba_control_irq(udc, &udc->usba_ep[i]);
>


--
Nicolas Ferre
0 new messages