USB: atmel: add atmel usba udc driver support
Subsystems (3)
v2 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 OK on at91sam9m10g45ek, at91sam9m10g45ek, and sama5d31ek boards.
It need the patch from: Troy Kisky <[email protected]> (usb: gadget: config: fix unaligned access issues)
more information: http://patchwork.ozlabs.org/patch/264151/
Changes in v2:
- Add detail information of the orignal code
- Add a common header to hold atmel usba udc information for different SoCs
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/atmel_usba_udc.h | 64 ++ arch/arm/include/asm/arch-at91/sama5d3.h | 2 +- board/atmel/sama5d3xek/sama5d3xek.c | 13 + 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 + 10 files changed, 1757 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/arch-at91/atmel_usba_udc.h 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
PATCH v2 1/3 USB: gadget: add atmel usba udc driver
Add atmel usba udc driver support, porting from Linux kernel
The original code in Linux Kernel information is as following
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.
---
Changes in v2:
- Add detail information of the orignal code
--- 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
@@ -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
@@ -0,0 +1,26 @@ +/* +* Platform data definitions for Atmel USBA gadget driver +* [Original 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
PATCH v2 1/3 USB: gadget: add atmel usba udc driver
Dear Bo Shen,
Quoted 8 lines
Add atmel usba udc driver support, porting from Linux kernel
The original code in Linux Kernel information is as following
commit
e01ee9f509a927158f670408b41127d4166db1c7Author: Jingoo Han <[email protected]> Date: Tue Jul 30 17:00:51 2013 +0900
Quoted 6 lines
usb: gadget: use
dev_get_platdata()Use the wrapper function for retrieving the platform data instead of accessing
dev->platform_datadirectly.Signed-off-by Bo Shen <[email protected]>
The glue code seems OK.
Best regards,
Marek Vasut
PATCH v2 2/3 ARM: atmel: correct UDPHS name
In reply to Bo ShenCorrect the UDPHS name from UDHPS
---
Changes in v2:
- None
--- 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
@@ -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
PATCH v2 2/3 ARM: atmel: correct UDPHS name
Dear Bo Shen,
Quoted 3 lines
Correct the UDPHS name from UDHPS
Signed-off-by Bo Shen <[email protected]>
Best regards,
Marek Vasut
PATCH v2 3/3 ARM: atmel: add RNDIS gadget support
In reply to Bo ShenAdd RNDIS gadget support to test atmel usba udc driver
---
Changes in v2:
- Add a common header to hold atmel usba udc information for different SoCs
--- 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/atmel_usba_udc.h | 64 +++++++++++++++++++++++ board/atmel/sama5d3xek/sama5d3xek.c | 13 +++++ include/configs/sama5d3xek.h | 8 +++ 5 files changed, 98 insertions(+) create mode 100644 arch/arm/include/asm/arch-at91/atmel_usba_udc.h
arch/arm/cpu/armv7/at91/sama5d3_devices.c +12 -0
@@ -202,3 +202,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
@@ -19,6 +19,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 );
arch/arm/include/asm/arch-at91/atmel_usba_udc.h new file +64 -0
64 lines not on this page · raw message
board/atmel/sama5d3xek/sama5d3xek.c +13 -0
@@ -21,6 +21,10 @@#include <net.h> #include <netdev.h> +#ifdef CONFIG_USB_GADGET_ATMEL_USBA +#include <asm/arch/atmel_usba_udc.h> +#endif +DECLARE_GLOBAL_DATA_PTR ;/* ------------------------------------------------------------------------- */
@@ -170,6 +174,9 @@ int board_init(void)#ifdef CONFIG_CMD_USB 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
@@ -221,6 +228,12 @@ int board_eth_init(bd_t *bis)if (has_gmac ()) rc =macb_eth_initialize (0 , (void *)ATMEL_BASE_GMAC ,0x00 );#endif +#ifdef CONFIG_USB_GADGET_ATMEL_USBA +usba_udc_probe (&pdata); +#ifdef CONFIG_USB_ETH_RNDIS +usb_eth_initialize (bis); +#endif +#endif return rc; }
include/configs/sama5d3xek.h +8 -0
@@ -162,6 +162,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
PATCH v2 3/3 ARM: atmel: add RNDIS gadget support
Dear Bo Shen,
arch/arm/include/asm/arch-at91/atmel_usba_udc.h
Quoted 56 lines
Add RNDIS gadget support to test atmel usba udc driver
Signed-off-by Bo Shen <[email protected]>---
Changes in v2:
- Add a common header to hold atmel usba udc information for different SoCs--- 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/atmel_usba_udc.h | 64 +++++++++++++++++++++++ board/atmel/sama5d3xek/sama5d3xek.c | 13 +++++ include/configs/sama5d3xek.h | 8 +++ 5 files changed, 98 insertions(+) create mode 100644 arch/arm/include/asm/arch-at91/atmel_usba_udc.h(quoted diff) +0
-0
b/arch/arm/cpu/armv7/at91/sama5d3_devices.cindex e55e1c6..51f0a6d 100644arch/arm/cpu/armv7/at91/sama5d3_devices.c +12
-0@@ -202,3 +202,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.hindex 9f54fdd..abcb97d 100644arch/arm/include/asm/arch-at91/at91_common.h +1
-0@@ -19,6 +19,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/arch/arm/include/asm/arch-at91/atmel_usba_udc.hnew file mode 100644 index 0000000..6f540d2arch/arm/include/asm/arch-at91/atmel_usba_udc.h new file +0
-0
This new file should be added alongside the USB driver, not board stuff.
[...]
Best regards,
Marek Vasut
PATCH v2 3/3 ARM: atmel: add RNDIS gadget support
Hi Marek Vasut,
Quoted 53 lines · Marek Vasut
Dear Bo Shen,
Quoted 51 lines
Add RNDIS gadget support to test atmel usba udc driver
Signed-off-by Bo Shen <[email protected]>---
Changes in v2:
- Add a common header to hold atmel usba udc information for different SoCs--- 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/atmel_usba_udc.h | 64 +++++++++++++++++++++++ board/atmel/sama5d3xek/sama5d3xek.c | 13 +++++ include/configs/sama5d3xek.h | 8 +++ 5 files changed, 98 insertions(+)create mode 100644
arch/arm/include/asm/arch-at91/atmel_usba_udc.h(quoted diff) +0
-0
b/arch/arm/cpu/armv7/at91/sama5d3_devices.cindex e55e1c6..51f0a6d 100644arch/arm/cpu/armv7/at91/sama5d3_devices.c +12
-0@@ -202,3 +202,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.hindex 9f54fdd..abcb97d 100644arch/arm/include/asm/arch-at91/at91_common.h +1
-0@@ -19,6 +19,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 7 lines
arch/arm/include/asm/arch-at91/atmel_usba_udc.h
Quoted 5 lines
(quoted diff) +0
-0
b/arch/arm/include/asm/arch-at91/atmel_usba_udc.hnew file mode 100644 index 0000000..6f540d2arch/arm/include/asm/arch-at91/atmel_usba_udc.h new file +0
-0This new file should be added alongside the USB driver, not board stuff.
OK, I will move this file into USB driver patch.
Quoted 5 lines
[...]
Best regards,
Marek Vasut
Best Regards,
Bo Shen
v2 cover USB: atmel: add atmel usba udc driver support
In reply to Bo ShenDear Bo Shen,
Quoted 8 lines
Add atmel usb udc driver support porting from Linux kernel. Using RNDIS gadget driver to test it.
Test OK on at91sam9m10g45ek, at91sam9m10g45ek, and sama5d31ek boards.
It need the patch from: Troy Kisky <[email protected]> (usb: gadget: config: fix unaligned access issues)
more information: http://patchwork.ozlabs.org/patch/264151/
You might need to fix that patch yourself and resubmit it, I remember some comments about it.
Best regards,
Marek Vasut
v2 cover USB: atmel: add atmel usba udc driver support
Hi Marek Vasut,
Quoted 5 lines · Marek Vasut
Dear Bo Shen,
Quoted 3 lines
Add atmel usb udc driver support porting from Linux kernel. Using RNDIS gadget driver to test it.
Quoted 8 lines
Quoted 5 lines
Test OK on at91sam9m10g45ek, at91sam9m10g45ek, and sama5d31ek boards.
It need the patch from: Troy Kisky <[email protected]> (usb: gadget: config: fix unaligned access issues)
more information: http://patchwork.ozlabs.org/patch/264151/You might need to fix that patch yourself and resubmit it, I remember some comments about it.
OK, I will resubmit it
Quoted 3 lines
Best regards,
Marek Vasut
Best Regards,
Bo Shen