USB/gadget: PXA27x USB device support
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 USB/gadget: PXA27x USB device support
Hello,
here my new proposal for PXA27x USB device support. In this version I fixed the power management support (suspend/resume).
As already mentioned in my previous, I know this driver is quite far from perfection but, in my opinion, it could be a good starting point to add this support into the kernel.
I use the driver from my platform specific file into "arch/arm/mach-pxa/" by using the following code:
static int wwpc1100_udc_is_connected (void)
{
return 1;
}static void wwpc1100_udc_command (int cmd)
{
switch (cmd) {
case PXA2XX_UDC_CMD_DISCONNECT:
pr_debug("%s: disconnect\n", __FUNCTION__);
break;
case PXA2XX_UDC_CMD_CONNECT:
pr_debug("%s: connect\n", __FUNCTION__);
break;
default:
printk(KERN_ERR "%s: unknown command!\n", __FUNCTION__);
break;
}
}static struct pxa2xx_udc_mach_info wwpc1100_udc_mach_info = {
.udc_is_connected = wwpc1100_udc_is_connected,
.udc_command = wwpc1100_udc_command,
.gpio_pullup = WWPC1100_USBD_ENABLE,};
Where WWPC1100_USBD_ENABLE is the GPIO number connected to a pull-up on USB lines.
Please note that I'm using this driver under linux-2.6.20-rc6 but the patch applies to linux-2.6.21-rc2!
The patch is also available at «http://ftp.enneenne.com/pub/misc/pxa270-patches/linux/pxa27x-udc-support.2
---
drivers/usb/gadget/Kconfig +18 -0
@@ -111,6 +111,24 @@ config USB_PXA2XX default USB_GADGET select USB_GADGET_SELECTED +config USB_GADGET_PXA27X + boolean "PXA 27x" + depends on ARCH_PXA && PXA27x + help + Intel's PXA 27x series XScale processors include an integrated + full speed USB 1.1 device controller. + + Say "y" to link the driver statically, or "m" to build a + dynamically linked module called "pxa2xx_udc" and force all + gadget drivers to also be dynamically linked. + + +config USB_PXA27X + tristate + depends on USB_GADGET_PXA27X + default USB_GADGET + select USB_GADGET_SELECTED + # if there's only one gadget driver, using only two bulk endpoints, # don't waste memory for the other endpoints config USB_PXA2XX_SMALL
drivers/usb/gadget/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o obj-$(CONFIG_USB_NET2280) += net2280.o obj-$(CONFIG_USB_PXA2XX) += pxa2xx_udc.o +obj-$(CONFIG_USB_PXA27X) += pxa27x_udc.o obj-$(CONFIG_USB_GOKU) += goku_udc.o obj-$(CONFIG_USB_OMAP) += omap_udc.o obj-$(CONFIG_USB_LH7A40X) += lh7a40x_udc.o
drivers/usb/gadget/epautoconf.c +7 -1
@@ -230,7 +230,8 @@ find_ep (struct usb_gadget *gadget, const char *name)*/ struct usb_ep *__devinit usb_ep_autoconfig (struct usb_gadget *gadget, -struct usb_endpoint_descriptor *desc +struct usb_endpoint_descriptor *desc, +int config,int interface,int alt ) {struct usb_ep *ep;
@@ -238,6 +239,11 @@ struct usb_ep * __devinit usb_ep_autoconfig ( type = desc->bmAttributes &USB_ENDPOINT_XFERTYPE_MASK ; +/* If have ep_alloc() function use it! */ +if (gadget->ops->ep_alloc) +return gadget->ops->ep_alloc (gadget, desc, + config, interface, alt); +/* First, apply chip-specific "best usage" knowledge. * This might make a good usb_gadget_ops hook ... */
drivers/usb/gadget/ether.c +53 -9
109 lines not on this page · raw message
drivers/usb/gadget/file_storage.c +3 -3
@@ -3920,20 +3920,20 @@ static int __init fsg_bind(struct usb_gadget *gadget)/* Find all the endpoints we will use */ usb_ep_autoconfig_reset (gadget); - ep =usb_ep_autoconfig (gadget, &fs_bulk_in_desc); + ep =usb_ep_autoconfig (gadget, &fs_bulk_in_desc,0 ,0 ,0 );if (!ep) goto autoconf_fail; ep->driver_data = fsg;// claim the endpoint fsg->bulk_in = ep; - ep =usb_ep_autoconfig (gadget, &fs_bulk_out_desc); + ep =usb_ep_autoconfig (gadget, &fs_bulk_out_desc,0 ,0 ,0 );if (!ep) goto autoconf_fail; ep->driver_data = fsg;// claim the endpoint fsg->bulk_out = ep;if (transport_is_cbi ()) { - ep =usb_ep_autoconfig (gadget, &fs_intr_in_desc); + ep =usb_ep_autoconfig (gadget, &fs_intr_in_desc,0 ,0 ,0 );if (!ep) goto autoconf_fail; ep->driver_data = fsg;// claim the endpoint
drivers/usb/gadget/gadget_chips.h +2 -0
@@ -177,5 +177,7 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)return 0x17 ; else if (gadget_is_husb2dev(gadget)) return 0x18; + else if (gadget_is_pxa27x(gadget)) + return 0x19;return -ENOENT ; }
drivers/usb/gadget/gmidi.c +2 -2
@@ -1204,7 +1204,7 @@ static int __devinit gmidi_bind(struct usb_gadget *gadget)* but there may also be important quirks to address. */ usb_ep_autoconfig_reset (gadget); - in_ep =usb_ep_autoconfig (gadget, &bulk_in_desc); + in_ep =usb_ep_autoconfig (gadget, &bulk_in_desc,0 ,0 ,0 );if (!in_ep) { autoconf_fail: printk(KERN_ERR "%s: can't autoconfigure on %s\n",
@@ -1214,7 +1214,7 @@ autoconf_fail:EP_IN_NAME = in_ep->name; in_ep->driver_data = in_ep;/* claim */ - out_ep =usb_ep_autoconfig (gadget, &bulk_out_desc); + out_ep =usb_ep_autoconfig (gadget, &bulk_out_desc,0 ,0 ,0 );if (!out_ep) { goto autoconf_fail; }
drivers/usb/gadget/pxa27x_udc.c new file +2354 -0
2,354 lines not on this page · raw message
drivers/usb/gadget/pxa27x_udc.h new file +329 -0
329 lines not on this page · raw message
drivers/usb/gadget/serial.c +3 -3
@@ -1378,20 +1378,20 @@ static int __init gs_bind(struct usb_gadget *gadget)usb_ep_autoconfig_reset (gadget); - ep =usb_ep_autoconfig (gadget, &gs_fullspeed_in_desc); + ep =usb_ep_autoconfig (gadget, &gs_fullspeed_in_desc,0 ,0 ,0 );if (!ep) goto autoconf_fail;EP_IN_NAME = ep->name; ep->driver_data = ep;/* claim the endpoint */ - ep =usb_ep_autoconfig (gadget, &gs_fullspeed_out_desc); + ep =usb_ep_autoconfig (gadget, &gs_fullspeed_out_desc,0 ,0 ,0 );if (!ep) goto autoconf_fail;EP_OUT_NAME = ep->name; ep->driver_data = ep;/* claim the endpoint */ if (use_acm) { - ep =usb_ep_autoconfig (gadget, &gs_fullspeed_notify_desc); + ep =usb_ep_autoconfig (gadget, &gs_fullspeed_notify_desc,0 ,0 ,0 );if (!ep) {printk (KERN_ERR "gs_bind: cannot run ACM on %s\n" , gadget->name); goto autoconf_fail;
drivers/usb/gadget/zero.c +2 -2
@@ -1155,7 +1155,7 @@ zero_bind (struct usb_gadget *gadget)* but there may also be important quirks to address. */ usb_ep_autoconfig_reset (gadget); - ep =usb_ep_autoconfig (gadget, &fs_source_desc); + ep =usb_ep_autoconfig (gadget, &fs_source_desc,0 ,0 ,0 );if (!ep) { autoconf_fail: printk (KERN_ERR "%s: can't autoconfigure on %s\n",
@@ -1165,7 +1165,7 @@ autoconf_fail:EP_IN_NAME = ep->name; ep->driver_data = ep;/* claim */ - ep =usb_ep_autoconfig (gadget, &fs_sink_desc); + ep =usb_ep_autoconfig (gadget, &fs_sink_desc,0 ,0 ,0 );if (!ep) goto autoconf_fail;EP_OUT_NAME = ep->name;
include/linux/usb_gadget.h +20 -1
@@ -445,10 +445,28 @@ usb_ep_fifo_flush (struct usb_ep *ep)struct usb_gadget ; +/** +* struct usb_endpoint_config - possible configurations of a given endpoint +* @config: the configuration number +* @interface: the interface number +* @altinterface: the altinterface number +* +* Used as an array to pass information about the possible configurations +* of a given endpoint to the bus controller. +*/ +struct usb_endpoint_config { +int config; +int interface; +int altinterface; +}; +/* the rest of the api to the controller hardware: device operations, * which don't involve endpoints (or i/o). */ struct usb_gadget_ops { +struct usb_ep * (*ep_alloc)(struct usb_gadget *gadget, +struct usb_endpoint_descriptor *desc, +int config,int interface,int alt);int (*get_frame)(struct usb_gadget *);int (*wakeup)(struct usb_gadget *);int (*set_selfpowered) (struct usb_gadget *,int is_selfpowered);
@@ -872,7 +890,8 @@ int usb_gadget_config_buf(const struct usb_config_descriptor *config,/* utility wrapping a simple endpoint selection policy */ extern struct usb_ep *usb_ep_autoconfig (struct usb_gadget *, -struct usb_endpoint_descriptor *)__devinit ; +struct usb_endpoint_descriptor *, +int ,int ,int )__devinit ;extern void usb_ep_autoconfig_reset (struct usb_gadget *)__devinit ;
Quoted 11 lines · Rodolfo Giometti
Hello,
here my new proposal for PXA27x USB device support. In this version I fixed the power management support (suspend/resume).
As already mentioned in my previous, I know this driver is quite far from perfection but, in my opinion, it could be a good starting point to add this support into the kernel.
I use the driver from my platform specific file into "
arch/arm/mach-pxa/" by using the following code:
There is some code which might be useful in:
http://www.rpsys.net/openzaurus/patches/usb_add_epalloc-r3.patch
http://www.rpsys.net/openzaurus/patches/usb_pxa27x_udc-r3.patch
In the past I've tried to merge other peoples changes into these to make one more useful driver but there are known issues with try to merge either of these into mainline (particularly RNDIS support).
Cheers,
Richard