Skip to contentSkip to conversation

USB: atmel: add atmel usba udc driver support

RFC PATCH Superseded Bo Shen 3 participants 15 messages Sep 3, 2013 – Sep 4, 2013

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Bo Shen

author
#0 lore raw

cover USB: atmel: add atmel usba udc driver support

Add atmel usb udc driver support porting from Linux kernel. Using RNDIS gadget driver to test it.
Test it on sama5d31ek and sam9x5ek board.

Bo Shen (3):
USB: gadget: add atmel usba udc driver
ARM: atmel: correct UDPHS name
ARM: atmel: add RNDIS gadget support

 arch/arm/cpu/armv7/at91/sama5d3_devices.c    |   12 +
 arch/arm/include/asm/arch-at91/at91_common.h |    1 +
 arch/arm/include/asm/arch-at91/sama5d3.h     |    2 +-
 board/atmel/sama5d3xek/sama5d3xek.c          |   51 +
 drivers/usb/gadget/Makefile                  |    1 +
 drivers/usb/gadget/atmel_usba_udc.c          | 1305 ++++++++++++++++++++++++++
 drivers/usb/gadget/atmel_usba_udc.h          |  326 +++++++
 include/configs/sama5d3xek.h                 |    8 +
 include/linux/usb/atmel_usba_udc.h           |   26 +
 9 files changed, 1731 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/gadget/atmel_usba_udc.c
 create mode 100644 drivers/usb/gadget/atmel_usba_udc.h
 create mode 100644 include/linux/usb/atmel_usba_udc.h
Signature · 1 line
1.7.9.5
author
#1 lore raw

RFC PATCH 1/3 USB: gadget: add atmel usba udc driver

Add atmel usba udc driver support, porting from Linux kernel

---
 drivers/usb/gadget/Makefile         |    1 +
 drivers/usb/gadget/atmel_usba_udc.c | 1305 +++++++++++++++++++++++++++++++++++
 drivers/usb/gadget/atmel_usba_udc.h |  326 +++++++++
 include/linux/usb/atmel_usba_udc.h  |   26 +
 4 files changed, 1658 insertions(+)
 create mode 100644 drivers/usb/gadget/atmel_usba_udc.c
 create mode 100644 drivers/usb/gadget/atmel_usba_udc.h
 create mode 100644 include/linux/usb/atmel_usba_udc.h
drivers/usb/gadget/Makefile +1 -0
index 4c2a39a..4d51f59 100644
@@ -18,6 +18,7 @@ endif
 
 # new USB gadget layer dependencies
 ifdef CONFIG_USB_GADGET
+COBJS-$(CONFIG_USB_GADGET_ATMEL_USBA) += atmel_usba_udc.o
 COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o
 COBJS-$(CONFIG_USB_GADGET_FOTG210) += fotg210.o
 COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o
drivers/usb/gadget/atmel_usba_udc.c new file +1305 -0

1,305 lines not on this page · raw message

drivers/usb/gadget/atmel_usba_udc.h new file +326 -0

326 lines not on this page · raw message

include/linux/usb/atmel_usba_udc.h new file +26 -0
new file mode 100644
index 0000000..2303c92
@@ -0,0 +1,26 @@
+/*
+ * Platform data definitions for Atmel USBA gadget driver
+ * [Orignal from Linux kernel: include/linux/usb/atmel_usba_udc.h]
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+#ifndef __LINUX_USB_USBA_H__
+#define __LINUX_USB_USBA_H__
+
+struct usba_ep_data {
+	char *name;
+	int index;
+	int fifo_size;
+	int nr_banks;
+	int can_dma;
+	int can_isoc;
+};
+
+struct usba_platform_data {
+	int			num_ep;
+	struct usba_ep_data	*ep;
+};
+
+extern int usba_udc_probe(struct usba_platform_data *pdata);
+
+#endif /* __LINUX_USB_USBA_H */
Signature · 1 line
1.7.9.5
author
#3 lore raw

RFC PATCH 1/3 USB: gadget: add atmel usba udc driver

Hi Marek Vasut,

Quoted 10 lines · Marek Vasut

Dear Bo Shen,

Quoted 3 lines

Add atmel usba udc driver support, porting from Linux kernel

Please see [1] , point 4. I miss the exact point in Linux kernel history (read commit hash) from which this code was imported at least.

[1] http://www.denx.de/wiki/view/U-Boot/Patches#Attributing_Code_Copyrights_Sign

Thanks.

I will add this information into v2 after you finish reviewing the code.

The original code information from Linux kernel as following ---8>---
commit e01ee9f509a927158f670408b41127d4166db1c7

Author: Jingoo Han <[email protected]>
Date:   Tue Jul 30 17:00:51 2013 +0900

usb: gadget: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly.

---<8---

Quoted 5 lines

[...]

Best regards,
Marek Vasut

Best Regards,
Bo Shen

#4 lore raw

RFC PATCH 1/3 USB: gadget: add atmel usba udc driver

Dear Bo Shen,

Quoted 26 lines

Hi Marek Vasut,

Quoted 4 lines · Marek Vasut

Dear Bo Shen,

Quoted 2 lines

Add atmel usba udc driver support, porting from Linux kernel

Quoted 8 lines
Quoted 1 line

Please see [1] , point 4. I miss the exact point in Linux kernel history (read commit hash) from which this code was imported at least.

[1]
http://www.denx.de/wiki/view/U-Boot/Patches#Attributing_Code_Copyrights_
Sign

Thanks.

I will add this information into v2 after you finish reviewing the code.

The original code information from Linux kernel as following ---8>---
commit e01ee9f509a927158f670408b41127d4166db1c7

Author: Jingoo Han <[email protected]>
Date:   Tue Jul 30 17:00:51 2013 +0900
Quoted 9 lines

usb: gadget: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly.

---<8---

The code looks pretty much OK.

Best regards,
Marek Vasut

author
#5 lore raw

RFC PATCH 2/3 ARM: atmel: correct UDPHS name

In reply to Bo Shen
---
 arch/arm/include/asm/arch-at91/sama5d3.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/arch-at91/sama5d3.h +1 -1
index 49bd335..b9d574d 100644
@@ -120,7 +120,7 @@
 #define ATMEL_BASE_USART3	0xf8024000
 #define ATMEL_BASE_UART1	0xf8028000
 #define ATMEL_BASE_EMAC		0xf802c000
-#define ATMEL_BASE_UDHPS	0xf8030000
+#define ATMEL_BASE_UDPHS	0xf8030000
 #define ATMEL_BASE_SHA		0xf8034000
 #define ATMEL_BASE_AES		0xf8038000
 #define ATMEL_BASE_TDES		0xf803c000
Signature · 1 line
1.7.9.5
author
#6 lore raw

RFC PATCH 3/3 ARM: atmel: add RNDIS gadget support

In reply to Bo Shen

Add RNDIS gadget support to test atmel usba udc driver

---
 arch/arm/cpu/armv7/at91/sama5d3_devices.c    |   12 ++++++
 arch/arm/include/asm/arch-at91/at91_common.h |    1 +
 board/atmel/sama5d3xek/sama5d3xek.c          |   51 ++++++++++++++++++++++++++
 include/configs/sama5d3xek.h                 |    8 ++++
 4 files changed, 72 insertions(+)
arch/arm/cpu/armv7/at91/sama5d3_devices.c +12 -0
index 4a3fca5..12c6d08 100644
@@ -178,3 +178,15 @@ void at91_lcd_hw_init(void)
 	at91_periph_clk_enable(ATMEL_ID_LCDC);
 }
 #endif
+
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+void at91_udp_hw_init(void)
+{
+	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+	/* Enable UPLL clock */
+	writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+	/* Enable UDPHS clock */
+	at91_periph_clk_enable(ATMEL_ID_UDPHS);
+}
+#endif
arch/arm/include/asm/arch-at91/at91_common.h +1 -0
index d659702..7acc1b0 100644
@@ -18,6 +18,7 @@ void at91_serial2_hw_init(void);
 void at91_seriald_hw_init(void);
 void at91_spi0_hw_init(unsigned long cs_mask);
 void at91_spi1_hw_init(unsigned long cs_mask);
+void at91_udp_hw_init(void);
 void at91_uhp_hw_init(void);
 void at91_lcd_hw_init(void);
 
board/atmel/sama5d3xek/sama5d3xek.c +51 -0

75 lines not on this page · raw message

include/configs/sama5d3xek.h +8 -0
index 10697d6..002ddd2 100644
@@ -161,6 +161,14 @@
 #define CONFIG_USB_STORAGE
 #endif
 
+/* USB device */
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_ATMEL_USBA
+#define CONFIG_USB_ETHER
+#define CONFIG_USB_ETH_RNDIS
+#define CONFIG_USBNET_MANUFACTURER      "Atmel SAMA5D3xEK"
+
 #if defined(CONFIG_CMD_USB) || defined(CONFIG_CMD_MMC)
 #define CONFIG_CMD_FAT
 #endif
Signature · 1 line
1.7.9.5
#7 lore raw

RFC PATCH 3/3 ARM: atmel: add RNDIS gadget support

Dear Bo Shen,

Quoted 94 lines

Add RNDIS gadget support to test atmel usba udc driver

---
 arch/arm/cpu/armv7/at91/sama5d3_devices.c    |   12 ++++++
 arch/arm/include/asm/arch-at91/at91_common.h |    1 +
 board/atmel/sama5d3xek/sama5d3xek.c          |   51
++++++++++++++++++++++++++ include/configs/sama5d3xek.h                 | 
  8 ++++
 4 files changed, 72 insertions(+)
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/at91/sama5d3_devices.c index 4a3fca5..12c6d08 100644

arch/arm/cpu/armv7/at91/sama5d3_devices.c +12 -0
@@ -178,3 +178,15 @@ void at91_lcd_hw_init(void)
 	at91_periph_clk_enable(ATMEL_ID_LCDC);
 }
 #endif
+
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+void at91_udp_hw_init(void)
+{
+	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+	/* Enable UPLL clock */
+	writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+	/* Enable UDPHS clock */
+	at91_periph_clk_enable(ATMEL_ID_UDPHS);
+}
+#endif
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-at91/at91_common.h index d659702..7acc1b0 100644

arch/arm/include/asm/arch-at91/at91_common.h +1 -0
@@ -18,6 +18,7 @@ void at91_serial2_hw_init(void);
 void at91_seriald_hw_init(void);
 void at91_spi0_hw_init(unsigned long cs_mask);
 void at91_spi1_hw_init(unsigned long cs_mask);
+void at91_udp_hw_init(void);
 void at91_uhp_hw_init(void);
 void at91_lcd_hw_init(void);
 
(quoted diff) +0 -0

b/board/atmel/sama5d3xek/sama5d3xek.c index 4a309ad..161e8ed 100644

board/atmel/sama5d3xek/sama5d3xek.c +4 -1
@@ -20,6 +20,10 @@
 #include <net.h>
 #include <netdev.h>
 
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+#include <linux/usb/atmel_usba_udc.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 /*
-------------------------------------------------------------------------

*/ @@ -169,6 +173,9 @@ int board_init(void)
#ifdef CONFIG_CMD_USB

board/atmel/sama5d3xek/sama5d3xek.c +22 -0
 	sama5d3xek_usb_hw_init();
 #endif
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+	at91_udp_hw_init();
+#endif
 #ifdef CONFIG_GENERIC_ATMEL_MCI
 	sama5d3xek_mci_hw_init();
 #endif
@@ -193,6 +200,44 @@ int dram_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+#define EP(nam, idx, maxpkt, maxbk, dma, isoc)		\
+	[idx] = {					\
+		.name	= nam,				\
+		.index	= idx,				\
+		.fifo_size	= maxpkt,		\
+		.nr_banks	= maxbk,		\
+		.can_dma	= dma,			\
+		.can_isoc	= isoc,			\
+	}
+
+static struct usba_ep_data usba_udc_ep[] = {
+	EP("ep0", 0, 64, 1, 0, 0),
+	EP("ep1", 1, 1024, 3, 1, 0),
+	EP("ep2", 2, 1024, 3, 1, 0),
+	EP("ep3", 3, 1024, 2, 1, 0),
+	EP("ep4", 4, 1024, 2, 1, 0),
+	EP("ep5", 5, 1024, 2, 1, 0),
+	EP("ep6", 6, 1024, 2, 1, 0),

board/atmel/sama5d3xek/sama5d3xek.c int dram_init(void) · line 231

Quoted 10 lines
board/atmel/sama5d3xek/sama5d3xek.c +10 -0
+	EP("ep7", 7, 1024, 2, 1, 0),
+	EP("ep8", 8, 1024, 2, 0, 0),
+	EP("ep9", 9, 1024, 2, 0, 0),
+	EP("ep10", 10, 1024, 2, 0, 0),
+	EP("ep11", 11, 1024, 2, 0, 0),
+	EP("ep12", 12, 1024, 2, 0, 0),
+	EP("ep13", 13, 1024, 2, 0, 0),
+	EP("ep14", 14, 1024, 2, 0, 0),
+	EP("ep15", 15, 1024, 2, 0, 0),
+};

Can this not be part of the driver itself ?

author
#8 lore raw

RFC PATCH 3/3 ARM: atmel: add RNDIS gadget support

Hi Marek Vasut,

On 09/04/2013 06:31 AM, Marek Vasut wrote:

[snip]

Quoted 23 lines
Quoted 23 lines
board/atmel/sama5d3xek/sama5d3xek.c +23 -0
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+#define EP(nam, idx, maxpkt, maxbk, dma, isoc)		\
+	[idx] = {					\
+		.name	= nam,				\
+		.index	= idx,				\
+		.fifo_size	= maxpkt,		\
+		.nr_banks	= maxbk,		\
+		.can_dma	= dma,			\
+		.can_isoc	= isoc,			\
+	}
+
+static struct usba_ep_data usba_udc_ep[] = {
+	EP("ep0", 0, 64, 1, 0, 0),
+	EP("ep1", 1, 1024, 3, 1, 0),
+	EP("ep2", 2, 1024, 3, 1, 0),
+	EP("ep3", 3, 1024, 2, 1, 0),
+	EP("ep4", 4, 1024, 2, 1, 0),
+	EP("ep5", 5, 1024, 2, 1, 0),
+	EP("ep6", 6, 1024, 2, 1, 0),
+	EP("ep7", 7, 1024, 2, 1, 0),
+	EP("ep8", 8, 1024, 2, 0, 0),
+	EP("ep9", 9, 1024, 2, 0, 0),
+	EP("ep10", 10, 1024, 2, 0, 0),
Quoted 9 lines

board/atmel/sama5d3xek/sama5d3xek.c int dram_init(void) · line 231

Quoted 6 lines
board/atmel/sama5d3xek/sama5d3xek.c +6 -0
+	EP("ep11", 11, 1024, 2, 0, 0),
+	EP("ep12", 12, 1024, 2, 0, 0),
+	EP("ep13", 13, 1024, 2, 0, 0),
+	EP("ep14", 14, 1024, 2, 0, 0),
+	EP("ep15", 15, 1024, 2, 0, 0),
+};

Can this not be part of the driver itself ?

I have considered to put this in driver, however, different Atmel SoC have different attributes for each endpoint and different number of endpoint.

for example;
at91sam9x5: EP("ep1", 1, 1024, 2, 1, 1)
sama5d3x: EP("ep1", 1, 1024, 3, 1, 0)

So, if I put this in driver, there will be many #ifdef. If newly SoC added, maybe we will need to add #ifdef again. So, I put it here.

Best Regards,
Bo Shen

#9 lore raw

RFC PATCH 3/3 ARM: atmel: add RNDIS gadget support

Dear Bo Shen,

Quoted 42 lines

Hi Marek Vasut,

On 09/04/2013 06:31 AM, Marek Vasut wrote:

[snip]

Quoted 23 lines
Quoted 23 lines
board/atmel/sama5d3xek/sama5d3xek.c +23 -0
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+#define EP(nam, idx, maxpkt, maxbk, dma, isoc)		\
+	[idx] = {					\
+		.name	= nam,				\
+		.index	= idx,				\
+		.fifo_size	= maxpkt,		\
+		.nr_banks	= maxbk,		\
+		.can_dma	= dma,			\
+		.can_isoc	= isoc,			\
+	}
+
+static struct usba_ep_data usba_udc_ep[] = {
+	EP("ep0", 0, 64, 1, 0, 0),
+	EP("ep1", 1, 1024, 3, 1, 0),
+	EP("ep2", 2, 1024, 3, 1, 0),
+	EP("ep3", 3, 1024, 2, 1, 0),
+	EP("ep4", 4, 1024, 2, 1, 0),
+	EP("ep5", 5, 1024, 2, 1, 0),
+	EP("ep6", 6, 1024, 2, 1, 0),
+	EP("ep7", 7, 1024, 2, 1, 0),
+	EP("ep8", 8, 1024, 2, 0, 0),
+	EP("ep9", 9, 1024, 2, 0, 0),
+	EP("ep10", 10, 1024, 2, 0, 0),
Quoted 8 lines

board/atmel/sama5d3xek/sama5d3xek.c int dram_init(void) · line 231

Quoted 6 lines
board/atmel/sama5d3xek/sama5d3xek.c +6 -0
+	EP("ep11", 11, 1024, 2, 0, 0),
+	EP("ep12", 12, 1024, 2, 0, 0),
+	EP("ep13", 13, 1024, 2, 0, 0),
+	EP("ep14", 14, 1024, 2, 0, 0),
+	EP("ep15", 15, 1024, 2, 0, 0),
+};

Can this not be part of the driver itself ?

I have considered to put this in driver, however, different Atmel SoC have different attributes for each endpoint and different number of endpoint.

Quoted 6 lines

for example;
at91sam9x5: EP("ep1", 1, 1024, 2, 1, 1)
sama5d3x: EP("ep1", 1, 1024, 3, 1, 0)

So, if I put this in driver, there will be many #ifdef. If newly SoC added, maybe we will need to add #ifdef again. So, I put it here.

Can you not pull it into some header file at least? Having it in the board file will clearly result in duplication.

Best regards,
Marek Vasut

author
#10 lore raw

RFC PATCH 3/3 ARM: atmel: add RNDIS gadget support

Hi Marek Vasut,

Quoted 4 lines · Marek Vasut
Quoted 4 lines
Quoted 4 lines

I have considered to put this in driver, however, different Atmel SoC have different attributes for each endpoint and different number of endpoint.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

for example;
at91sam9x5: EP("ep1", 1, 1024, 2, 1, 1)
sama5d3x: EP("ep1", 1, 1024, 3, 1, 0)

So, if I put this in driver, there will be many #ifdef. If newly SoC added, maybe we will need to add #ifdef again. So, I put it here.

Can you not pull it into some header file at least? Having it in the board file will clearly result in duplication.

OK, I will put it into header file.
Thanks,

Quoted 2 lines

Best regards,
Marek Vasut

Best Regards,
Bo Shen

#11 lore raw

RFC PATCH 3/3 ARM: atmel: add RNDIS gadget support

Hi Bo, Marek,

Quoted 11 lines · Bo Shen

Hi Marek Vasut,

Quoted 8 lines · Marek Vasut
Quoted 8 lines
Quoted 8 lines

I have considered to put this in driver, however, different Atmel SoC have different attributes for each endpoint and different number of endpoint.

for example;
at91sam9x5: EP("ep1", 1, 1024, 2, 1, 1)
sama5d3x: EP("ep1", 1, 1024, 3, 1, 0)

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

So, if I put this in driver, there will be many #ifdef. If newly SoC added, maybe we will need to add #ifdef again. So, I put it here.

Can you not pull it into some header file at least? Having it in the board file
will clearly result in duplication.

OK, I will put it into header file.

I'm fine with a header too. But for the records, the mentioned file is _not_ board code but SoC code.

Best regards

Andreas Bie?mann

author
#12 lore raw

RFC PATCH 3/3 ARM: atmel: add RNDIS gadget support

Hi Andreas,

Quoted 16 lines · Andreas Bie?mann

Hi Bo, Marek,

Quoted 13 lines · Bo Shen

Hi Marek Vasut,

Quoted 10 lines · Marek Vasut
Quoted 10 lines
Quoted 10 lines

I have considered to put this in driver, however, different Atmel SoC have different attributes for each endpoint and different number of endpoint.

for example;
at91sam9x5: EP("ep1", 1, 1024, 2, 1, 1)
sama5d3x: EP("ep1", 1, 1024, 3, 1, 0)

So, if I put this in driver, there will be many #ifdef. If newly SoC added, maybe we will need to add #ifdef again. So, I put it here.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Can you not pull it into some header file at least? Having it in the board file
will clearly result in duplication.

OK, I will put it into header file.

I'm fine with a header too. But for the records, the mentioned file is _not_ board code but SoC code.

I will create a header file named atmel_usba_udc.h as other peripheral (at91_udc.h is reserved for full speed usb device), and put it under "arm/arm/include/asm/arch-at91/", the contents as following, does it OK?

---8>---
/*
* Copyright (C) 2005-2013 Atmel Corporation
* Bo Shen <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0+
*/

#ifndef __ATMEL_USBA_UDC_H__
#define __ATMEL_USBA_UDC_H__

#include <linux/usb/atmel_usba_udc.h>

#define EP(nam, idx, maxpkt, maxbk, dma, isoc)          \
         [idx] = {                                       \
                 .name   = nam,                          \
                 .index  = idx,                          \
                 .fifo_size      = maxpkt,               \
                 .nr_banks       = maxbk,                \
                 .can_dma        = dma,                  \
                 .can_isoc       = isoc,                 \
         }
#if defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
         defined(CONFIG_AT91SAM9X5)
static struct usba_ep_data usba_udc_ep[] = {
         EP("ep0", 0, 64, 1, 0, 0),
	... ...
         EP("ep6", 6, 1024, 3, 1, 1),
};
#elif defined(CONFIG_SAMA5D3)
static struct usba_ep_data usba_udc_ep[] = {
         EP("ep0", 0, 64, 1, 0, 0),
         ..
         EP("ep15", 15, 1024, 2, 0, 0),
 
 
                   };
#else
# error "NO usba_udc_ep defined"
#endif

#undef EP

struct usba_platform_data pdata = {
.num_ep = ARRAY_SIZE(usba_udc_ep),
.ep = usba_udc_ep,
};

#endif
---<8---

Quoted 4 lines

Best regards

Andreas Bie?mann

Best Regards,
Bo Shen

#13 lore raw

RFC PATCH 3/3 ARM: atmel: add RNDIS gadget support

Hi Bo,

Quoted 76 lines · Bo Shen

Hi Andreas,

Quoted 16 lines · Andreas Bie?mann

Hi Bo, Marek,

Quoted 13 lines · Bo Shen

Hi Marek Vasut,

Quoted 10 lines · Marek Vasut
Quoted 10 lines
Quoted 10 lines

I have considered to put this in driver, however, different Atmel SoC have different attributes for each endpoint and different number of endpoint.

for example;
at91sam9x5: EP("ep1", 1, 1024, 2, 1, 1)
sama5d3x: EP("ep1", 1, 1024, 3, 1, 0)

So, if I put this in driver, there will be many #ifdef. If newly SoC added, maybe we will need to add #ifdef again. So, I put it here.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Can you not pull it into some header file at least? Having it in the board file
will clearly result in duplication.

OK, I will put it into header file.

I'm fine with a header too. But for the records, the mentioned file is _not_ board code but SoC code.

I will create a header file named atmel_usba_udc.h as other peripheral (at91_udc.h is reserved for full speed usb device), and put it under "arm/arm/include/asm/arch-at91/", the contents as following, does it OK?

---8>---
/*
* Copyright (C) 2005-2013 Atmel Corporation
* Bo Shen <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0+
*/

#ifndef __ATMEL_USBA_UDC_H__
#define __ATMEL_USBA_UDC_H__

#include <linux/usb/atmel_usba_udc.h>

#define EP(nam, idx, maxpkt, maxbk, dma, isoc)          \
        [idx] = {                                       \
                .name   = nam,                          \
                .index  = idx,                          \
                .fifo_size      = maxpkt,               \
                .nr_banks       = maxbk,                \
                .can_dma        = dma,                  \
                .can_isoc       = isoc,                 \
        }
#if defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
        defined(CONFIG_AT91SAM9X5)
static struct usba_ep_data usba_udc_ep[] = {
        EP("ep0", 0, 64, 1, 0, 0),
    ... ...
        EP("ep6", 6, 1024, 3, 1, 1),
};
#elif defined(CONFIG_SAMA5D3)
static struct usba_ep_data usba_udc_ep[] = {
        EP("ep0", 0, 64, 1, 0, 0),
        ..
        EP("ep15", 15, 1024, 2, 0, 0),


                  };
#else
# error "NO usba_udc_ep defined"
#endif

#undef EP

Quoted 7 lines

struct usba_platform_data pdata = {
.num_ep = ARRAY_SIZE(usba_udc_ep),
.ep = usba_udc_ep,
};

#endif
---<8---

I'm fine with that. Was the g45/9X5 defined before or is it new in that patch?

Best regards

Andreas Bie?mann

#14 lore raw

RFC PATCH 3/3 ARM: atmel: add RNDIS gadget support

Dear Andreas Bie?mann,

Quoted 96 lines

Hi Bo,

Quoted 93 lines · Bo Shen

Hi Andreas,

Quoted 17 lines · Andreas Bie?mann

Hi Bo, Marek,

Quoted 14 lines · Bo Shen

Hi Marek Vasut,

Quoted 11 lines · Marek Vasut
Quoted 10 lines
Quoted 10 lines

I have considered to put this in driver, however, different Atmel SoC have different attributes for each endpoint and different number of endpoint.

for example;
at91sam9x5: EP("ep1", 1, 1024, 2, 1, 1)
sama5d3x: EP("ep1", 1, 1024, 3, 1, 0)

So, if I put this in driver, there will be many #ifdef. If newly SoC added, maybe we will need to add #ifdef again. So, I put it here.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Can you not pull it into some header file at least? Having it in the board file
will clearly result in duplication.

OK, I will put it into header file.

I'm fine with a header too. But for the records, the mentioned file is _not_ board code but SoC code.

I will create a header file named atmel_usba_udc.h as other peripheral (at91_udc.h is reserved for full speed usb device), and put it under "arm/arm/include/asm/arch-at91/", the contents as following, does it OK?

---8>---
/*

* Copyright (C) 2005-2013 Atmel Corporation
* Bo Shen <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0+
*/

#ifndef __ATMEL_USBA_UDC_H__
#define __ATMEL_USBA_UDC_H__

#include <linux/usb/atmel_usba_udc.h>

#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \

        [idx] = {                                       \
        
                .name   = nam,                          \
                .index  = idx,                          \
                .fifo_size      = maxpkt,               \
                .nr_banks       = maxbk,                \
                .can_dma        = dma,                  \
                .can_isoc       = isoc,                 \
        
        }

#if defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \

        defined(CONFIG_AT91SAM9X5)

static struct usba_ep_data usba_udc_ep[] = {

        EP("ep0", 0, 64, 1, 0, 0),
    
    ... ...
    
        EP("ep6", 6, 1024, 3, 1, 1),

};
#elif defined(CONFIG_SAMA5D3)
static struct usba_ep_data usba_udc_ep[] = {

        EP("ep0", 0, 64, 1, 0, 0),
        ..
        EP("ep15", 15, 1024, 2, 0, 0),
        
                  };

#else

# error "NO usba_udc_ep defined"
#endif

#undef EP

struct usba_platform_data pdata = {

.num_ep = ARRAY_SIZE(usba_udc_ep),
.ep = usba_udc_ep,

Quoted 6 lines
Quoted 4 lines

};

#endif
---<8---

I'm fine with that.

Same here, I'm fine with it

Best regards,
Marek Vasut