usb: add support R8A66597 peripheral controller driver
PATCH 1/1 usb: add support R8A66597 peripheral controller driver
The R8A66597 is Renesas USB 2.0 host and peripheral controller. This controller supports USB High-speed. This driver supports peripheral side.
--- drivers/usb/gadget/Kconfig | 18 + drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/gadget_chips.h | 8 + drivers/usb/gadget/r8a66597-udc.c | 1635 +++++++++++++++++++++++++++++++++++++ drivers/usb/gadget/r8a66597-udc.h | 249 ++++++ 5 files changed, 1911 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/gadget/r8a66597-udc.c create mode 100644 drivers/usb/gadget/r8a66597-udc.h
drivers/usb/gadget/Kconfig +18 -0
@@ -251,6 +251,24 @@ config USB_PXA25X_SMALL default y if USB_ETH default y if USB_G_SERIAL +config USB_GADGET_R8A66597 + boolean "Renesas R8A66597 USB Peripheral Controller" + select USB_GADGET_DUALSPEED + help + R8A66597 is a discrete USB host and peripheral controller chip that + supports both full and high speed USB 2.0 data transfers. + It has nine configurable endpoints, and endpoint zero. + + Say "y" to link the driver statically, or "m" to build a + dynamically linked module called "r8a66597_udc" and force all + gadget drivers to also be dynamically linked. + +config USB_R8A66597 + tristate + depends on USB_GADGET_R8A66597 + default USB_GADGET + select USB_GADGET_SELECTED + config USB_GADGET_PXA27X boolean "PXA 27x" depends on ARCH_PXA && (PXA27x || PXA3xx)
drivers/usb/gadget/Makefile +1 -0
@@ -23,6 +23,7 @@ ifeq ($(CONFIG_ARCH_MXC),y) fsl_usb2_udc-objs += fsl_mx3_udc.o endif obj-$(CONFIG_USB_M66592) += m66592-udc.o +obj-$(CONFIG_USB_R8A66597) += r8a66597-udc.o obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o obj-$(CONFIG_USB_CI13XXX) += ci13xxx_udc.o obj-$(CONFIG_USB_S3C_HSOTG) += s3c-hsotg.o
drivers/usb/gadget/gadget_chips.h +8 -0
@@ -173,6 +173,12 @@// CONFIG_USB_GADGET_AU1X00 // ... +#ifdef CONFIG_USB_GADGET_R8A66597 +#define gadget_is_r8a66597 (g) !strcmp("r8a66597_udc", (g)->name) +#else +#define gadget_is_r8a66597 (g) 0 +#endif +/** * usb_gadget_controller_number - support bcdDevice id convention
@@ -239,6 +245,8 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)return 0x23 ; else if (gadget_is_langwell(gadget)) return 0x24; + else if (gadget_is_r8a66597(gadget)) + return 0x25;return -ENOENT ; }
drivers/usb/gadget/r8a66597-udc.c new file +1635 -0
1,635 lines not on this page · raw message
drivers/usb/gadget/r8a66597-udc.h new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
1.5.5
Hi Shimoda-san,
[CC Paul]
Quoted 5 lines · Yoshihiro Shimoda
The R8A66597 is Renesas USB 2.0 host and peripheral controller. This controller supports USB High-speed. This driver supports peripheral side.
Signed-off-by Yoshihiro Shimoda <[email protected]>
Thanks for your work on this. I've tested this driver on a ms7724se board together with my two recently posted patches. I tested with CONFIG_USB_CDC_COMPOSITE and I can successfully transfer files to my PC using the USB connection. So all seems fine.
Greg, I suggest that this driver and future modifications are picked up by Paul. He has a stack of changes already.
Cheers,
/ magnus
Quoted 17 lines · Magnus Damm
Hi Shimoda-san,
[CC Paul]
Quoted 5 lines · Yoshihiro Shimoda
The R8A66597 is Renesas USB 2.0 host and peripheral controller. This controller supports USB High-speed. This driver supports peripheral side.
Signed-off-by Yoshihiro Shimoda <[email protected]>Thanks for your work on this. I've tested this driver on a ms7724se board together with my two recently posted patches. I tested with
CONFIG_USB_CDC_COMPOSITEand I can successfully transfer files to my PC using the USB connection. So all seems fine.
Quoted 4 lines
Tested-by Magnus Damm <[email protected]>Greg, I suggest that this driver and future modifications are picked up by Paul. He has a stack of changes already.
No objection from me.
thanks,
greg k-h
Quoted 7 lines · Yoshihiro Shimoda
The R8A66597 is Renesas USB 2.0 host and peripheral controller. This controller supports USB High-speed. This driver supports peripheral side.
drivers/usb/gadget/r8a66597-udc.c new file +3
-0+static struct usb_ep_ops r8a66597_ep_ops = { + .enable = r8a66597_enable, + .disable = r8a66597_disable,
drivers/usb/gadget/r8a66597-udc.c line 1375
Quoted 10 lines
drivers/usb/gadget/r8a66597-udc.c new file +10
-0+ + .alloc_request = r8a66597_alloc_request, + .free_request = r8a66597_free_request, + + .queue = r8a66597_queue, + .dequeue = r8a66597_dequeue, + + .set_halt = r8a66597_set_halt, + .fifo_flush = r8a66597_fifo_flush, +};
All new peripheral controller drivers should implement the set_wedge method.
Alan Stern
Quoted 18 lines · Greg KH
Quoted 17 lines · Magnus Damm
Hi Shimoda-san,
[CC Paul]
Quoted 5 lines · Yoshihiro Shimoda
The R8A66597 is Renesas USB 2.0 host and peripheral controller. This controller supports USB High-speed. This driver supports peripheral side.
Signed-off-by Yoshihiro Shimoda <[email protected]>Thanks for your work on this. I've tested this driver on a ms7724se board together with my two recently posted patches. I tested with
CONFIG_USB_CDC_COMPOSITEand I can successfully transfer files to my PC using the USB connection. So all seems fine.
Quoted 7 lines
Quoted 4 lines
Tested-by Magnus Damm <[email protected]>Greg, I suggest that this driver and future modifications are picked up by Paul. He has a stack of changes already.
No objection from me.
Thanks, I've rolled them in to the sh/r8a66597-udc topic branch. I think the only outstanding issue was Alan's comment, which will be addressed in a follow-up patch (and also looks like something we'll have to do for the m66592-udc case).
Quoted 6 lines · Alan Stern
Quoted 3 lines · Yoshihiro Shimoda
The R8A66597 is Renesas USB 2.0 host and peripheral controller. This controller supports USB High-speed. This driver supports peripheral side.
Quoted 16 lines
Review
Quoted 13 lines
(quoted diff) +13
-0+static struct usb_ep_ops r8a66597_ep_ops = { + .enable = r8a66597_enable, + .disable = r8a66597_disable, + + .alloc_request = r8a66597_alloc_request, + .free_request = r8a66597_free_request, + + .queue = r8a66597_queue, + .dequeue = r8a66597_dequeue, + + .set_halt = r8a66597_set_halt, + .fifo_flush = r8a66597_fifo_flush, +};All new peripheral controller drivers should implement the
set_wedgemethod.
Thank you very much for your comment!
I made a new patch of implement the set_wedge method. Would you check this patch?
Best regards,
Yoshihiro Shimoda
---
Subject: [PATCH] usb: r8a66597-udc: implement the set_wedge method
fix the problem that MSC Tests of USBCV detects some warnings.
--- drivers/usb/gadget/r8a66597-udc.c | 28 ++++++++++++++++++++++++++-- drivers/usb/gadget/r8a66597-udc.h | 1 + 2 files changed, 27 insertions(+), 2 deletions(-)
drivers/usb/gadget/r8a66597-udc.c +26 -2
@@ -974,8 +974,13 @@ static void clear_feature(struct r8a66597 *r8a66597,u16 w_index =le16_to_cpu (ctrl->wIndex); ep = r8a66597->epaddr2ep[w_index &USB_ENDPOINT_NUMBER_MASK ]; -pipe_stop (r8a66597, ep->pipenum); -control_reg_sqclr (r8a66597, ep->pipenum); +if (!ep->wedge) { +pipe_stop (r8a66597, ep->pipenum); +control_reg_sqclr (r8a66597, ep->pipenum); +spin_unlock (&r8a66597->lock); +usb_ep_clear_halt (&ep->ep); +spin_lock (&r8a66597->lock); + }control_end (r8a66597,1 );
@@ -1348,6 +1353,7 @@ static int r8a66597_set_halt(struct usb_ep *_ep, int value)pipe_stall (ep->r8a66597, ep->pipenum); }else { ep->busy =0 ; + ep->wedge =0 ;pipe_stop (ep->r8a66597, ep->pipenum); }
@@ -1356,6 +1362,23 @@ out:return ret; } +static int r8a66597_set_wedge (struct usb_ep *_ep) +{ +struct r8a66597_ep *ep; +unsigned long flags; + + ep = container_of(_ep, struct r8a66597_ep, ep); + +if (!ep || !ep->desc) +return -EINVAL ; + +spin_lock_irqsave (&ep->r8a66597->lock, flags); + ep->wedge =1 ; +spin_unlock_irqrestore (&ep->r8a66597->lock, flags); + +return usb_ep_set_halt (_ep); +} +static void r8a66597_fifo_flush (struct usb_ep *_ep) {struct r8a66597_ep *ep;
@@ -1381,6 +1404,7 @@ static struct usb_ep_ops r8a66597_ep_ops = { .dequeue = r8a66597_dequeue, .set_halt = r8a66597_set_halt, + .set_wedge = r8a66597_set_wedge, .fifo_flush = r8a66597_fifo_flush, };
drivers/usb/gadget/r8a66597-udc.h +1 -0
@@ -73,6 +73,7 @@ struct r8a66597_ep {struct list_head queue; unsigned busy:1; + unsigned wedge:1; unsigned internal_ccpl:1; /* use only control *//* this member can able to after r8a66597_enable */
Signature · 1 line
1.5.5
Quoted 24 lines · Yoshihiro Shimoda
Quoted 6 lines · Alan Stern
Quoted 3 lines · Yoshihiro Shimoda
The R8A66597 is Renesas USB 2.0 host and peripheral controller. This controller supports USB High-speed. This driver supports peripheral side.
Quoted 16 lines
drivers/usb/gadget/r8a66597-udc.c line 1375
Quoted 13 lines
drivers/usb/gadget/r8a66597-udc.c new file +13
-0+static struct usb_ep_ops r8a66597_ep_ops = { + .enable = r8a66597_enable, + .disable = r8a66597_disable, + + .alloc_request = r8a66597_alloc_request, + .free_request = r8a66597_free_request, + + .queue = r8a66597_queue, + .dequeue = r8a66597_dequeue, + + .set_halt = r8a66597_set_halt, + .fifo_flush = r8a66597_fifo_flush, +};All new peripheral controller drivers should implement the
set_wedgemethod.
Quoted 3 lines
Thank you very much for your comment!
I made a new patch of implement theset_wedgemethod. Would you check this patch?
It looks correct.
Alan Stern
Paul Mundt
AppliedQuoted 10 lines · Yoshihiro Shimoda
Subject: [PATCH] usb: r8a66597-udc: implement the
set_wedgemethodfix the problem that MSC Tests of USBCV detects some warnings.
Signed-off-by Yoshihiro Shimoda <[email protected]>--- drivers/usb/gadget/r8a66597-udc.c | 28 ++++++++++++++++++++++++++-- drivers/usb/gadget/r8a66597-udc.h | 1 + 2 files changed, 27 insertions(+), 2 deletions(-)
Applied, thanks.