mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-31 10:26:10 +01:00 
			
		
		
		
	Merge branch 'master' of git://git.denx.de/u-boot-usb
* 'master' of git://git.denx.de/u-boot-usb: USB: S5P: Add ehci support usb:udc:samsung Add functions for storing private gadget data in UDC driver usb:gadget:composite: Support for composite at gadget.h usb:gadget:composite USB composite gadget support usb:udc:samsung:cleanup Replace DEBUG_* macros with debug_cond() calls usb:udc: Remove duplicated USB definitions from include/linux/usb/ch9.h file USB: Document the QH and qTD antics in EHCI-HCD USB: Drop cache flush bloat in EHCI-HCD USB: Drop ehci_alloc/ehci_free in ehci-hcd USB: Align buffers at cacheline usb: use noinline define
This commit is contained in:
		
							
								
								
									
										66
									
								
								arch/arm/include/asm/arch-exynos/ehci-s5p.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								arch/arm/include/asm/arch-exynos/ehci-s5p.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | |||||||
|  | /* | ||||||
|  |  * SAMSUNG S5P USB HOST EHCI Controller | ||||||
|  |  * | ||||||
|  |  * Copyright (C) 2012 Samsung Electronics Co.Ltd | ||||||
|  |  *	Vivek Gautam <gautam.vivek@samsung.com> | ||||||
|  |  * | ||||||
|  |  * This program is free software; you can redistribute it and/or | ||||||
|  |  * modify it under the terms of the GNU General Public License as | ||||||
|  |  * published by the Free Software Foundation; either version 2 of | ||||||
|  |  * the License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with this program; if not, write to the Free Software | ||||||
|  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||||||
|  |  * MA 02110-1301 USA | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #ifndef __ASM_ARM_ARCH_EXYNOS5_EHCI_S5P_H__ | ||||||
|  | #define __ASM_ARM_ARCH_EXYNOS5_EHCI_S5P_H__ | ||||||
|  |  | ||||||
|  | #define CLK_24MHZ		5 | ||||||
|  |  | ||||||
|  | #define HOST_CTRL0_PHYSWRSTALL			(1 << 31) | ||||||
|  | #define HOST_CTRL0_COMMONON_N			(1 << 9) | ||||||
|  | #define HOST_CTRL0_SIDDQ			(1 << 6) | ||||||
|  | #define HOST_CTRL0_FORCESLEEP			(1 << 5) | ||||||
|  | #define HOST_CTRL0_FORCESUSPEND			(1 << 4) | ||||||
|  | #define HOST_CTRL0_WORDINTERFACE		(1 << 3) | ||||||
|  | #define HOST_CTRL0_UTMISWRST			(1 << 2) | ||||||
|  | #define HOST_CTRL0_LINKSWRST			(1 << 1) | ||||||
|  | #define HOST_CTRL0_PHYSWRST			(1 << 0) | ||||||
|  |  | ||||||
|  | #define HOST_CTRL0_FSEL_MASK			(7 << 16) | ||||||
|  |  | ||||||
|  | #define EHCICTRL_ENAINCRXALIGN			(1 << 29) | ||||||
|  | #define EHCICTRL_ENAINCR4			(1 << 28) | ||||||
|  | #define EHCICTRL_ENAINCR8			(1 << 27) | ||||||
|  | #define EHCICTRL_ENAINCR16			(1 << 26) | ||||||
|  |  | ||||||
|  | /* Register map for PHY control */ | ||||||
|  | struct s5p_usb_phy { | ||||||
|  | 	unsigned int usbphyctrl0; | ||||||
|  | 	unsigned int usbphytune0; | ||||||
|  | 	unsigned int reserved1[2]; | ||||||
|  | 	unsigned int hsicphyctrl1; | ||||||
|  | 	unsigned int hsicphytune1; | ||||||
|  | 	unsigned int reserved2[2]; | ||||||
|  | 	unsigned int hsicphyctrl2; | ||||||
|  | 	unsigned int hsicphytune2; | ||||||
|  | 	unsigned int reserved3[2]; | ||||||
|  | 	unsigned int ehcictrl; | ||||||
|  | 	unsigned int ohcictrl; | ||||||
|  | 	unsigned int usbotgsys; | ||||||
|  | 	unsigned int reserved4; | ||||||
|  | 	unsigned int usbotgtune; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | /* Switch on the VBUS power. */ | ||||||
|  | int board_usb_vbus_init(void); | ||||||
|  |  | ||||||
|  | #endif /* __ASM_ARM_ARCH_EXYNOS5_EHCI_S5P_H__ */ | ||||||
| @@ -150,7 +150,8 @@ void usb_display_class_sub(unsigned char dclass, unsigned char subclass, | |||||||
|  |  | ||||||
| void usb_display_string(struct usb_device *dev, int index) | void usb_display_string(struct usb_device *dev, int index) | ||||||
| { | { | ||||||
| 	char buffer[256]; | 	ALLOC_CACHE_ALIGN_BUFFER(char, buffer, 256); | ||||||
|  |  | ||||||
| 	if (index != 0) { | 	if (index != 0) { | ||||||
| 		if (usb_string(dev, index, &buffer[0], 256) > 0) | 		if (usb_string(dev, index, &buffer[0], 256) > 0) | ||||||
| 			printf("String: \"%s\"", buffer); | 			printf("String: \"%s\"", buffer); | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								common/usb.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								common/usb.c
									
									
									
									
									
								
							| @@ -47,6 +47,7 @@ | |||||||
| #include <common.h> | #include <common.h> | ||||||
| #include <command.h> | #include <command.h> | ||||||
| #include <asm/processor.h> | #include <asm/processor.h> | ||||||
|  | #include <linux/compiler.h> | ||||||
| #include <linux/ctype.h> | #include <linux/ctype.h> | ||||||
| #include <asm/byteorder.h> | #include <asm/byteorder.h> | ||||||
| #include <asm/unaligned.h> | #include <asm/unaligned.h> | ||||||
| @@ -169,7 +170,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, | |||||||
| 			unsigned short value, unsigned short index, | 			unsigned short value, unsigned short index, | ||||||
| 			void *data, unsigned short size, int timeout) | 			void *data, unsigned short size, int timeout) | ||||||
| { | { | ||||||
| 	struct devrequest setup_packet; | 	ALLOC_CACHE_ALIGN_BUFFER(struct devrequest, setup_packet, 1); | ||||||
|  |  | ||||||
| 	if ((timeout == 0) && (!asynch_allowed)) { | 	if ((timeout == 0) && (!asynch_allowed)) { | ||||||
| 		/* request for a asynch control pipe is not allowed */ | 		/* request for a asynch control pipe is not allowed */ | ||||||
| @@ -177,17 +178,17 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/* set setup command */ | 	/* set setup command */ | ||||||
| 	setup_packet.requesttype = requesttype; | 	setup_packet->requesttype = requesttype; | ||||||
| 	setup_packet.request = request; | 	setup_packet->request = request; | ||||||
| 	setup_packet.value = cpu_to_le16(value); | 	setup_packet->value = cpu_to_le16(value); | ||||||
| 	setup_packet.index = cpu_to_le16(index); | 	setup_packet->index = cpu_to_le16(index); | ||||||
| 	setup_packet.length = cpu_to_le16(size); | 	setup_packet->length = cpu_to_le16(size); | ||||||
| 	USB_PRINTF("usb_control_msg: request: 0x%X, requesttype: 0x%X, " \ | 	USB_PRINTF("usb_control_msg: request: 0x%X, requesttype: 0x%X, " \ | ||||||
| 		   "value 0x%X index 0x%X length 0x%X\n", | 		   "value 0x%X index 0x%X length 0x%X\n", | ||||||
| 		   request, requesttype, value, index, size); | 		   request, requesttype, value, index, size); | ||||||
| 	dev->status = USB_ST_NOT_PROC; /*not yet processed */ | 	dev->status = USB_ST_NOT_PROC; /*not yet processed */ | ||||||
|  |  | ||||||
| 	submit_control_msg(dev, pipe, data, size, &setup_packet); | 	submit_control_msg(dev, pipe, data, size, setup_packet); | ||||||
| 	if (timeout == 0) | 	if (timeout == 0) | ||||||
| 		return (int)size; | 		return (int)size; | ||||||
|  |  | ||||||
| @@ -261,7 +262,7 @@ int usb_maxpacket(struct usb_device *dev, unsigned long pipe) | |||||||
|  * |  * | ||||||
|  * NOTE: Similar behaviour was observed with GCC4.6 on ARMv5. |  * NOTE: Similar behaviour was observed with GCC4.6 on ARMv5. | ||||||
|  */ |  */ | ||||||
| static void  __attribute__((noinline)) | static void noinline | ||||||
| usb_set_maxpacket_ep(struct usb_device *dev, int if_idx, int ep_idx) | usb_set_maxpacket_ep(struct usb_device *dev, int if_idx, int ep_idx) | ||||||
| { | { | ||||||
| 	int b; | 	int b; | ||||||
| @@ -681,7 +682,7 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid, | |||||||
|  */ |  */ | ||||||
| int usb_string(struct usb_device *dev, int index, char *buf, size_t size) | int usb_string(struct usb_device *dev, int index, char *buf, size_t size) | ||||||
| { | { | ||||||
| 	unsigned char mybuf[USB_BUFSIZ]; | 	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, mybuf, USB_BUFSIZ); | ||||||
| 	unsigned char *tbuf; | 	unsigned char *tbuf; | ||||||
| 	int err; | 	int err; | ||||||
| 	unsigned int u, idx; | 	unsigned int u, idx; | ||||||
| @@ -781,7 +782,7 @@ int usb_new_device(struct usb_device *dev) | |||||||
| { | { | ||||||
| 	int addr, err; | 	int addr, err; | ||||||
| 	int tmp; | 	int tmp; | ||||||
| 	unsigned char tmpbuf[USB_BUFSIZ]; | 	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, tmpbuf, USB_BUFSIZ); | ||||||
|  |  | ||||||
| 	/* We still haven't set the Address yet */ | 	/* We still haven't set the Address yet */ | ||||||
| 	addr = dev->devnum; | 	addr = dev->devnum; | ||||||
| @@ -908,8 +909,8 @@ int usb_new_device(struct usb_device *dev) | |||||||
| 	le16_to_cpus(&dev->descriptor.idProduct); | 	le16_to_cpus(&dev->descriptor.idProduct); | ||||||
| 	le16_to_cpus(&dev->descriptor.bcdDevice); | 	le16_to_cpus(&dev->descriptor.bcdDevice); | ||||||
| 	/* only support for one config for now */ | 	/* only support for one config for now */ | ||||||
| 	usb_get_configuration_no(dev, &tmpbuf[0], 0); | 	usb_get_configuration_no(dev, tmpbuf, 0); | ||||||
| 	usb_parse_config(dev, &tmpbuf[0], 0); | 	usb_parse_config(dev, tmpbuf, 0); | ||||||
| 	usb_set_maxpacket(dev); | 	usb_set_maxpacket(dev); | ||||||
| 	/* we set the default configuration here */ | 	/* we set the default configuration here */ | ||||||
| 	if (usb_set_configuration(dev, dev->config.desc.bConfigurationValue)) { | 	if (usb_set_configuration(dev, dev->config.desc.bConfigurationValue)) { | ||||||
|   | |||||||
| @@ -153,7 +153,7 @@ int hub_port_reset(struct usb_device *dev, int port, | |||||||
| 			unsigned short *portstat) | 			unsigned short *portstat) | ||||||
| { | { | ||||||
| 	int tries; | 	int tries; | ||||||
| 	struct usb_port_status portsts; | 	ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1); | ||||||
| 	unsigned short portstatus, portchange; | 	unsigned short portstatus, portchange; | ||||||
|  |  | ||||||
| 	USB_HUB_PRINTF("hub_port_reset: resetting port %d...\n", port); | 	USB_HUB_PRINTF("hub_port_reset: resetting port %d...\n", port); | ||||||
| @@ -162,13 +162,13 @@ int hub_port_reset(struct usb_device *dev, int port, | |||||||
| 		usb_set_port_feature(dev, port + 1, USB_PORT_FEAT_RESET); | 		usb_set_port_feature(dev, port + 1, USB_PORT_FEAT_RESET); | ||||||
| 		mdelay(200); | 		mdelay(200); | ||||||
|  |  | ||||||
| 		if (usb_get_port_status(dev, port + 1, &portsts) < 0) { | 		if (usb_get_port_status(dev, port + 1, portsts) < 0) { | ||||||
| 			USB_HUB_PRINTF("get_port_status failed status %lX\n", | 			USB_HUB_PRINTF("get_port_status failed status %lX\n", | ||||||
| 					dev->status); | 					dev->status); | ||||||
| 			return -1; | 			return -1; | ||||||
| 		} | 		} | ||||||
| 		portstatus = le16_to_cpu(portsts.wPortStatus); | 		portstatus = le16_to_cpu(portsts->wPortStatus); | ||||||
| 		portchange = le16_to_cpu(portsts.wPortChange); | 		portchange = le16_to_cpu(portsts->wPortChange); | ||||||
|  |  | ||||||
| 		USB_HUB_PRINTF("portstatus %x, change %x, %s\n", | 		USB_HUB_PRINTF("portstatus %x, change %x, %s\n", | ||||||
| 				portstatus, portchange, | 				portstatus, portchange, | ||||||
| @@ -206,19 +206,19 @@ int hub_port_reset(struct usb_device *dev, int port, | |||||||
| void usb_hub_port_connect_change(struct usb_device *dev, int port) | void usb_hub_port_connect_change(struct usb_device *dev, int port) | ||||||
| { | { | ||||||
| 	struct usb_device *usb; | 	struct usb_device *usb; | ||||||
| 	struct usb_port_status portsts; | 	ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1); | ||||||
| 	unsigned short portstatus; | 	unsigned short portstatus; | ||||||
|  |  | ||||||
| 	/* Check status */ | 	/* Check status */ | ||||||
| 	if (usb_get_port_status(dev, port + 1, &portsts) < 0) { | 	if (usb_get_port_status(dev, port + 1, portsts) < 0) { | ||||||
| 		USB_HUB_PRINTF("get_port_status failed\n"); | 		USB_HUB_PRINTF("get_port_status failed\n"); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	portstatus = le16_to_cpu(portsts.wPortStatus); | 	portstatus = le16_to_cpu(portsts->wPortStatus); | ||||||
| 	USB_HUB_PRINTF("portstatus %x, change %x, %s\n", | 	USB_HUB_PRINTF("portstatus %x, change %x, %s\n", | ||||||
| 			portstatus, | 			portstatus, | ||||||
| 			le16_to_cpu(portsts.wPortChange), | 			le16_to_cpu(portsts->wPortChange), | ||||||
| 			portspeed(portstatus)); | 			portspeed(portstatus)); | ||||||
|  |  | ||||||
| 	/* Clear the connection change status */ | 	/* Clear the connection change status */ | ||||||
| @@ -267,7 +267,8 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port) | |||||||
| static int usb_hub_configure(struct usb_device *dev) | static int usb_hub_configure(struct usb_device *dev) | ||||||
| { | { | ||||||
| 	int i; | 	int i; | ||||||
| 	unsigned char buffer[USB_BUFSIZ], *bitmap; | 	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, USB_BUFSIZ); | ||||||
|  | 	unsigned char *bitmap; | ||||||
| 	struct usb_hub_descriptor *descriptor; | 	struct usb_hub_descriptor *descriptor; | ||||||
| 	struct usb_hub_device *hub; | 	struct usb_hub_device *hub; | ||||||
| #ifdef USB_HUB_DEBUG | #ifdef USB_HUB_DEBUG | ||||||
| @@ -389,16 +390,16 @@ static int usb_hub_configure(struct usb_device *dev) | |||||||
| 	usb_hub_power_on(hub); | 	usb_hub_power_on(hub); | ||||||
|  |  | ||||||
| 	for (i = 0; i < dev->maxchild; i++) { | 	for (i = 0; i < dev->maxchild; i++) { | ||||||
| 		struct usb_port_status portsts; | 		ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1); | ||||||
| 		unsigned short portstatus, portchange; | 		unsigned short portstatus, portchange; | ||||||
|  |  | ||||||
| 		if (usb_get_port_status(dev, i + 1, &portsts) < 0) { | 		if (usb_get_port_status(dev, i + 1, portsts) < 0) { | ||||||
| 			USB_HUB_PRINTF("get_port_status failed\n"); | 			USB_HUB_PRINTF("get_port_status failed\n"); | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		portstatus = le16_to_cpu(portsts.wPortStatus); | 		portstatus = le16_to_cpu(portsts->wPortStatus); | ||||||
| 		portchange = le16_to_cpu(portsts.wPortChange); | 		portchange = le16_to_cpu(portsts->wPortChange); | ||||||
| 		USB_HUB_PRINTF("Port %d Status %X Change %X\n", | 		USB_HUB_PRINTF("Port %d Status %X Change %X\n", | ||||||
| 				i + 1, portstatus, portchange); | 				i + 1, portstatus, portchange); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -79,8 +79,7 @@ static const unsigned char us_direction[256/8] = { | |||||||
| }; | }; | ||||||
| #define US_DIRECTION(x) ((us_direction[x>>3] >> (x & 7)) & 1) | #define US_DIRECTION(x) ((us_direction[x>>3] >> (x & 7)) & 1) | ||||||
|  |  | ||||||
| static unsigned char usb_stor_buf[512]; | static ccb usb_ccb __attribute__((aligned(ARCH_DMA_MINALIGN))); | ||||||
| static ccb usb_ccb; |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * CBI style |  * CBI style | ||||||
| @@ -210,17 +209,17 @@ int usb_stor_info(void) | |||||||
| static unsigned int usb_get_max_lun(struct us_data *us) | static unsigned int usb_get_max_lun(struct us_data *us) | ||||||
| { | { | ||||||
| 	int len; | 	int len; | ||||||
| 	unsigned char result; | 	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, result, 1); | ||||||
| 	len = usb_control_msg(us->pusb_dev, | 	len = usb_control_msg(us->pusb_dev, | ||||||
| 			      usb_rcvctrlpipe(us->pusb_dev, 0), | 			      usb_rcvctrlpipe(us->pusb_dev, 0), | ||||||
| 			      US_BBB_GET_MAX_LUN, | 			      US_BBB_GET_MAX_LUN, | ||||||
| 			      USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | 			      USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | ||||||
| 			      0, us->ifnum, | 			      0, us->ifnum, | ||||||
| 			      &result, sizeof(result), | 			      result, sizeof(char), | ||||||
| 			      USB_CNTL_TIMEOUT * 5); | 			      USB_CNTL_TIMEOUT * 5); | ||||||
| 	USB_STOR_PRINTF("Get Max LUN -> len = %i, result = %i\n", | 	USB_STOR_PRINTF("Get Max LUN -> len = %i, result = %i\n", | ||||||
| 			len, (int) result); | 			len, (int) *result); | ||||||
| 	return (len > 0) ? result : 0; | 	return (len > 0) ? *result : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| /******************************************************************************* | /******************************************************************************* | ||||||
| @@ -233,9 +232,6 @@ int usb_stor_scan(int mode) | |||||||
| 	unsigned char i; | 	unsigned char i; | ||||||
| 	struct usb_device *dev; | 	struct usb_device *dev; | ||||||
|  |  | ||||||
| 	/* GJ */ |  | ||||||
| 	memset(usb_stor_buf, 0, sizeof(usb_stor_buf)); |  | ||||||
|  |  | ||||||
| 	if (mode == 1) | 	if (mode == 1) | ||||||
| 		printf("       scanning bus for storage devices... "); | 		printf("       scanning bus for storage devices... "); | ||||||
|  |  | ||||||
| @@ -499,7 +495,7 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us) | |||||||
| 	int actlen; | 	int actlen; | ||||||
| 	int dir_in; | 	int dir_in; | ||||||
| 	unsigned int pipe; | 	unsigned int pipe; | ||||||
| 	umass_bbb_cbw_t cbw; | 	ALLOC_CACHE_ALIGN_BUFFER(umass_bbb_cbw_t, cbw, 1); | ||||||
|  |  | ||||||
| 	dir_in = US_DIRECTION(srb->cmd[0]); | 	dir_in = US_DIRECTION(srb->cmd[0]); | ||||||
|  |  | ||||||
| @@ -522,16 +518,16 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us) | |||||||
| 	/* always OUT to the ep */ | 	/* always OUT to the ep */ | ||||||
| 	pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out); | 	pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out); | ||||||
|  |  | ||||||
| 	cbw.dCBWSignature = cpu_to_le32(CBWSIGNATURE); | 	cbw->dCBWSignature = cpu_to_le32(CBWSIGNATURE); | ||||||
| 	cbw.dCBWTag = cpu_to_le32(CBWTag++); | 	cbw->dCBWTag = cpu_to_le32(CBWTag++); | ||||||
| 	cbw.dCBWDataTransferLength = cpu_to_le32(srb->datalen); | 	cbw->dCBWDataTransferLength = cpu_to_le32(srb->datalen); | ||||||
| 	cbw.bCBWFlags = (dir_in ? CBWFLAGS_IN : CBWFLAGS_OUT); | 	cbw->bCBWFlags = (dir_in ? CBWFLAGS_IN : CBWFLAGS_OUT); | ||||||
| 	cbw.bCBWLUN = srb->lun; | 	cbw->bCBWLUN = srb->lun; | ||||||
| 	cbw.bCDBLength = srb->cmdlen; | 	cbw->bCDBLength = srb->cmdlen; | ||||||
| 	/* copy the command data into the CBW command data buffer */ | 	/* copy the command data into the CBW command data buffer */ | ||||||
| 	/* DST SRC LEN!!! */ | 	/* DST SRC LEN!!! */ | ||||||
| 	memcpy(cbw.CBWCDB, srb->cmd, srb->cmdlen); | 	memcpy(cbw->CBWCDB, srb->cmd, srb->cmdlen); | ||||||
| 	result = usb_bulk_msg(us->pusb_dev, pipe, &cbw, UMASS_BBB_CBW_SIZE, | 	result = usb_bulk_msg(us->pusb_dev, pipe, cbw, UMASS_BBB_CBW_SIZE, | ||||||
| 			      &actlen, USB_CNTL_TIMEOUT * 5); | 			      &actlen, USB_CNTL_TIMEOUT * 5); | ||||||
| 	if (result < 0) | 	if (result < 0) | ||||||
| 		USB_STOR_PRINTF("usb_stor_BBB_comdat:usb_bulk_msg error\n"); | 		USB_STOR_PRINTF("usb_stor_BBB_comdat:usb_bulk_msg error\n"); | ||||||
| @@ -675,7 +671,7 @@ int usb_stor_BBB_transport(ccb *srb, struct us_data *us) | |||||||
| 	int dir_in; | 	int dir_in; | ||||||
| 	int actlen, data_actlen; | 	int actlen, data_actlen; | ||||||
| 	unsigned int pipe, pipein, pipeout; | 	unsigned int pipe, pipein, pipeout; | ||||||
| 	umass_bbb_csw_t csw; | 	ALLOC_CACHE_ALIGN_BUFFER(umass_bbb_csw_t, csw, 1); | ||||||
| #ifdef BBB_XPORT_TRACE | #ifdef BBB_XPORT_TRACE | ||||||
| 	unsigned char *ptr; | 	unsigned char *ptr; | ||||||
| 	int index; | 	int index; | ||||||
| @@ -733,7 +729,7 @@ st: | |||||||
| 	retry = 0; | 	retry = 0; | ||||||
| again: | again: | ||||||
| 	USB_STOR_PRINTF("STATUS phase\n"); | 	USB_STOR_PRINTF("STATUS phase\n"); | ||||||
| 	result = usb_bulk_msg(us->pusb_dev, pipein, &csw, UMASS_BBB_CSW_SIZE, | 	result = usb_bulk_msg(us->pusb_dev, pipein, csw, UMASS_BBB_CSW_SIZE, | ||||||
| 				&actlen, USB_CNTL_TIMEOUT*5); | 				&actlen, USB_CNTL_TIMEOUT*5); | ||||||
|  |  | ||||||
| 	/* special handling of STALL in STATUS phase */ | 	/* special handling of STALL in STATUS phase */ | ||||||
| @@ -753,28 +749,28 @@ again: | |||||||
| 		return USB_STOR_TRANSPORT_FAILED; | 		return USB_STOR_TRANSPORT_FAILED; | ||||||
| 	} | 	} | ||||||
| #ifdef BBB_XPORT_TRACE | #ifdef BBB_XPORT_TRACE | ||||||
| 	ptr = (unsigned char *)&csw; | 	ptr = (unsigned char *)csw; | ||||||
| 	for (index = 0; index < UMASS_BBB_CSW_SIZE; index++) | 	for (index = 0; index < UMASS_BBB_CSW_SIZE; index++) | ||||||
| 		printf("ptr[%d] %#x ", index, ptr[index]); | 		printf("ptr[%d] %#x ", index, ptr[index]); | ||||||
| 	printf("\n"); | 	printf("\n"); | ||||||
| #endif | #endif | ||||||
| 	/* misuse pipe to get the residue */ | 	/* misuse pipe to get the residue */ | ||||||
| 	pipe = le32_to_cpu(csw.dCSWDataResidue); | 	pipe = le32_to_cpu(csw->dCSWDataResidue); | ||||||
| 	if (pipe == 0 && srb->datalen != 0 && srb->datalen - data_actlen != 0) | 	if (pipe == 0 && srb->datalen != 0 && srb->datalen - data_actlen != 0) | ||||||
| 		pipe = srb->datalen - data_actlen; | 		pipe = srb->datalen - data_actlen; | ||||||
| 	if (CSWSIGNATURE != le32_to_cpu(csw.dCSWSignature)) { | 	if (CSWSIGNATURE != le32_to_cpu(csw->dCSWSignature)) { | ||||||
| 		USB_STOR_PRINTF("!CSWSIGNATURE\n"); | 		USB_STOR_PRINTF("!CSWSIGNATURE\n"); | ||||||
| 		usb_stor_BBB_reset(us); | 		usb_stor_BBB_reset(us); | ||||||
| 		return USB_STOR_TRANSPORT_FAILED; | 		return USB_STOR_TRANSPORT_FAILED; | ||||||
| 	} else if ((CBWTag - 1) != le32_to_cpu(csw.dCSWTag)) { | 	} else if ((CBWTag - 1) != le32_to_cpu(csw->dCSWTag)) { | ||||||
| 		USB_STOR_PRINTF("!Tag\n"); | 		USB_STOR_PRINTF("!Tag\n"); | ||||||
| 		usb_stor_BBB_reset(us); | 		usb_stor_BBB_reset(us); | ||||||
| 		return USB_STOR_TRANSPORT_FAILED; | 		return USB_STOR_TRANSPORT_FAILED; | ||||||
| 	} else if (csw.bCSWStatus > CSWSTATUS_PHASE) { | 	} else if (csw->bCSWStatus > CSWSTATUS_PHASE) { | ||||||
| 		USB_STOR_PRINTF(">PHASE\n"); | 		USB_STOR_PRINTF(">PHASE\n"); | ||||||
| 		usb_stor_BBB_reset(us); | 		usb_stor_BBB_reset(us); | ||||||
| 		return USB_STOR_TRANSPORT_FAILED; | 		return USB_STOR_TRANSPORT_FAILED; | ||||||
| 	} else if (csw.bCSWStatus == CSWSTATUS_PHASE) { | 	} else if (csw->bCSWStatus == CSWSTATUS_PHASE) { | ||||||
| 		USB_STOR_PRINTF("=PHASE\n"); | 		USB_STOR_PRINTF("=PHASE\n"); | ||||||
| 		usb_stor_BBB_reset(us); | 		usb_stor_BBB_reset(us); | ||||||
| 		return USB_STOR_TRANSPORT_FAILED; | 		return USB_STOR_TRANSPORT_FAILED; | ||||||
| @@ -782,7 +778,7 @@ again: | |||||||
| 		USB_STOR_PRINTF("transferred %dB instead of %ldB\n", | 		USB_STOR_PRINTF("transferred %dB instead of %ldB\n", | ||||||
| 			data_actlen, srb->datalen); | 			data_actlen, srb->datalen); | ||||||
| 		return USB_STOR_TRANSPORT_FAILED; | 		return USB_STOR_TRANSPORT_FAILED; | ||||||
| 	} else if (csw.bCSWStatus == CSWSTATUS_FAILED) { | 	} else if (csw->bCSWStatus == CSWSTATUS_FAILED) { | ||||||
| 		USB_STOR_PRINTF("FAILED\n"); | 		USB_STOR_PRINTF("FAILED\n"); | ||||||
| 		return USB_STOR_TRANSPORT_FAILED; | 		return USB_STOR_TRANSPORT_FAILED; | ||||||
| 	} | 	} | ||||||
| @@ -1343,7 +1339,8 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, | |||||||
| 		      block_dev_desc_t *dev_desc) | 		      block_dev_desc_t *dev_desc) | ||||||
| { | { | ||||||
| 	unsigned char perq, modi; | 	unsigned char perq, modi; | ||||||
| 	unsigned long cap[2]; | 	ALLOC_CACHE_ALIGN_BUFFER(unsigned long, cap, 2); | ||||||
|  | 	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, usb_stor_buf, 36); | ||||||
| 	unsigned long *capacity, *blksz; | 	unsigned long *capacity, *blksz; | ||||||
| 	ccb *pccb = &usb_ccb; | 	ccb *pccb = &usb_ccb; | ||||||
|  |  | ||||||
| @@ -1367,9 +1364,9 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, | |||||||
| 		/* drive is removable */ | 		/* drive is removable */ | ||||||
| 		dev_desc->removable = 1; | 		dev_desc->removable = 1; | ||||||
| 	} | 	} | ||||||
| 	memcpy(&dev_desc->vendor[0], &usb_stor_buf[8], 8); | 	memcpy(&dev_desc->vendor[0], (const void *) &usb_stor_buf[8], 8); | ||||||
| 	memcpy(&dev_desc->product[0], &usb_stor_buf[16], 16); | 	memcpy(&dev_desc->product[0], (const void *) &usb_stor_buf[16], 16); | ||||||
| 	memcpy(&dev_desc->revision[0], &usb_stor_buf[32], 4); | 	memcpy(&dev_desc->revision[0], (const void *) &usb_stor_buf[32], 4); | ||||||
| 	dev_desc->vendor[8] = 0; | 	dev_desc->vendor[8] = 0; | ||||||
| 	dev_desc->product[16] = 0; | 	dev_desc->product[16] = 0; | ||||||
| 	dev_desc->revision[4] = 0; | 	dev_desc->revision[4] = 0; | ||||||
|   | |||||||
							
								
								
									
										1082
									
								
								drivers/usb/gadget/composite.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1082
									
								
								drivers/usb/gadget/composite.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -27,6 +27,7 @@ | |||||||
| #include <linux/string.h> | #include <linux/string.h> | ||||||
|  |  | ||||||
| #include <linux/usb/ch9.h> | #include <linux/usb/ch9.h> | ||||||
|  | #include <usbdescriptors.h> | ||||||
| #include <linux/usb/gadget.h> | #include <linux/usb/gadget.h> | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,6 +23,7 @@ | |||||||
|  |  | ||||||
| #include <common.h> | #include <common.h> | ||||||
| #include <linux/usb/ch9.h> | #include <linux/usb/ch9.h> | ||||||
|  | #include <usbdescriptors.h> | ||||||
| #include <asm/errno.h> | #include <asm/errno.h> | ||||||
| #include <linux/usb/gadget.h> | #include <linux/usb/gadget.h> | ||||||
| #include <asm/unaligned.h> | #include <asm/unaligned.h> | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ | |||||||
| #include <asm/errno.h> | #include <asm/errno.h> | ||||||
| #include <linux/netdevice.h> | #include <linux/netdevice.h> | ||||||
| #include <linux/usb/ch9.h> | #include <linux/usb/ch9.h> | ||||||
|  | #include <usbdescriptors.h> | ||||||
| #include <linux/usb/cdc.h> | #include <linux/usb/cdc.h> | ||||||
| #include <linux/usb/gadget.h> | #include <linux/usb/gadget.h> | ||||||
| #include <net.h> | #include <net.h> | ||||||
|   | |||||||
| @@ -30,13 +30,14 @@ | |||||||
|  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
|  | #undef DEBUG | ||||||
| #include <common.h> | #include <common.h> | ||||||
| #include <asm/errno.h> | #include <asm/errno.h> | ||||||
| #include <linux/list.h> | #include <linux/list.h> | ||||||
| #include <malloc.h> | #include <malloc.h> | ||||||
|  |  | ||||||
| #include <linux/usb/ch9.h> | #include <linux/usb/ch9.h> | ||||||
|  | #include <usbdescriptors.h> | ||||||
| #include <linux/usb/gadget.h> | #include <linux/usb/gadget.h> | ||||||
|  |  | ||||||
| #include <asm/byteorder.h> | #include <asm/byteorder.h> | ||||||
| @@ -53,19 +54,11 @@ | |||||||
|  |  | ||||||
| #define OTG_DMA_MODE		1 | #define OTG_DMA_MODE		1 | ||||||
|  |  | ||||||
| #undef DEBUG_S3C_UDC_SETUP | #define DEBUG_SETUP 0 | ||||||
| #undef DEBUG_S3C_UDC_EP0 | #define DEBUG_EP0 0 | ||||||
| #undef DEBUG_S3C_UDC_ISR | #define DEBUG_ISR 0 | ||||||
| #undef DEBUG_S3C_UDC_OUT_EP | #define DEBUG_OUT_EP 0 | ||||||
| #undef DEBUG_S3C_UDC_IN_EP | #define DEBUG_IN_EP 0 | ||||||
| #undef DEBUG_S3C_UDC |  | ||||||
|  |  | ||||||
| /* #define DEBUG_S3C_UDC_SETUP */ |  | ||||||
| /* #define DEBUG_S3C_UDC_EP0 */ |  | ||||||
| /* #define DEBUG_S3C_UDC_ISR */ |  | ||||||
| /* #define DEBUG_S3C_UDC_OUT_EP */ |  | ||||||
| /* #define DEBUG_S3C_UDC_IN_EP */ |  | ||||||
| /* #define DEBUG_S3C_UDC */ |  | ||||||
|  |  | ||||||
| #include <usb/s3c_udc.h> | #include <usb/s3c_udc.h> | ||||||
|  |  | ||||||
| @@ -132,6 +125,19 @@ static void nuke(struct s3c_ep *ep, int status); | |||||||
| static int s3c_udc_set_halt(struct usb_ep *_ep, int value); | static int s3c_udc_set_halt(struct usb_ep *_ep, int value); | ||||||
| static void s3c_udc_set_nak(struct s3c_ep *ep); | static void s3c_udc_set_nak(struct s3c_ep *ep); | ||||||
|  |  | ||||||
|  | void set_udc_gadget_private_data(void *p) | ||||||
|  | { | ||||||
|  | 	debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 		   "%s: the_controller: 0x%p, p: 0x%p\n", __func__, | ||||||
|  | 		   the_controller, p); | ||||||
|  | 	the_controller->gadget.dev.device_data = p; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void *get_udc_gadget_private_data(struct usb_gadget *gadget) | ||||||
|  | { | ||||||
|  | 	return gadget->dev.device_data; | ||||||
|  | } | ||||||
|  |  | ||||||
| static struct usb_ep_ops s3c_ep_ops = { | static struct usb_ep_ops s3c_ep_ops = { | ||||||
| 	.enable = s3c_ep_enable, | 	.enable = s3c_ep_enable, | ||||||
| 	.disable = s3c_ep_disable, | 	.disable = s3c_ep_disable, | ||||||
| @@ -216,7 +222,7 @@ void otg_phy_off(struct s3c_udc *dev) | |||||||
|  */ |  */ | ||||||
| static void udc_disable(struct s3c_udc *dev) | static void udc_disable(struct s3c_udc *dev) | ||||||
| { | { | ||||||
| 	DEBUG_SETUP("%s: %p\n", __func__, dev); | 	debug_cond(DEBUG_SETUP != 0, "%s: %p\n", __func__, dev); | ||||||
|  |  | ||||||
| 	udc_set_address(dev, 0); | 	udc_set_address(dev, 0); | ||||||
|  |  | ||||||
| @@ -234,7 +240,7 @@ static void udc_reinit(struct s3c_udc *dev) | |||||||
| { | { | ||||||
| 	unsigned int i; | 	unsigned int i; | ||||||
|  |  | ||||||
| 	DEBUG_SETUP("%s: %p\n", __func__, dev); | 	debug_cond(DEBUG_SETUP != 0, "%s: %p\n", __func__, dev); | ||||||
|  |  | ||||||
| 	/* device/ep0 records init */ | 	/* device/ep0 records init */ | ||||||
| 	INIT_LIST_HEAD(&dev->gadget.ep_list); | 	INIT_LIST_HEAD(&dev->gadget.ep_list); | ||||||
| @@ -265,12 +271,13 @@ static void udc_reinit(struct s3c_udc *dev) | |||||||
|  */ |  */ | ||||||
| static int udc_enable(struct s3c_udc *dev) | static int udc_enable(struct s3c_udc *dev) | ||||||
| { | { | ||||||
| 	DEBUG_SETUP("%s: %p\n", __func__, dev); | 	debug_cond(DEBUG_SETUP != 0, "%s: %p\n", __func__, dev); | ||||||
|  |  | ||||||
| 	otg_phy_init(dev); | 	otg_phy_init(dev); | ||||||
| 	reconfig_usbd(); | 	reconfig_usbd(); | ||||||
|  |  | ||||||
| 	DEBUG_SETUP("S3C USB 2.0 OTG Controller Core Initialized : 0x%x\n", | 	debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 		   "S3C USB 2.0 OTG Controller Core Initialized : 0x%x\n", | ||||||
| 		    readl(®->gintmsk)); | 		    readl(®->gintmsk)); | ||||||
|  |  | ||||||
| 	dev->gadget.speed = USB_SPEED_UNKNOWN; | 	dev->gadget.speed = USB_SPEED_UNKNOWN; | ||||||
| @@ -287,7 +294,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||||||
| 	int retval = 0; | 	int retval = 0; | ||||||
| 	unsigned long flags; | 	unsigned long flags; | ||||||
|  |  | ||||||
| 	DEBUG_SETUP("%s: %s\n", __func__, "no name"); | 	debug_cond(DEBUG_SETUP != 0, "%s: %s\n", __func__, "no name"); | ||||||
|  |  | ||||||
| 	if (!driver | 	if (!driver | ||||||
| 	    || (driver->speed != USB_SPEED_FULL | 	    || (driver->speed != USB_SPEED_FULL | ||||||
| @@ -311,7 +318,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||||||
|  |  | ||||||
| 	retval = driver->bind(&dev->gadget); | 	retval = driver->bind(&dev->gadget); | ||||||
| 	if (retval) { | 	if (retval) { | ||||||
| 		DEBUG_SETUP("%s: bind to driver --> error %d\n", | 		debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 			   "%s: bind to driver --> error %d\n", | ||||||
| 			    dev->gadget.name, retval); | 			    dev->gadget.name, retval); | ||||||
| 		dev->driver = 0; | 		dev->driver = 0; | ||||||
| 		return retval; | 		return retval; | ||||||
| @@ -319,7 +327,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||||||
|  |  | ||||||
| 	enable_irq(IRQ_OTG); | 	enable_irq(IRQ_OTG); | ||||||
|  |  | ||||||
| 	DEBUG_SETUP("Registered gadget driver %s\n", dev->gadget.name); | 	debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 		   "Registered gadget driver %s\n", dev->gadget.name); | ||||||
| 	udc_enable(dev); | 	udc_enable(dev); | ||||||
|  |  | ||||||
| 	return 0; | 	return 0; | ||||||
| @@ -377,7 +386,7 @@ static void done(struct s3c_ep *ep, struct s3c_request *req, int status) | |||||||
| 	/* don't modify queue heads during completion callback */ | 	/* don't modify queue heads during completion callback */ | ||||||
| 	ep->stopped = 1; | 	ep->stopped = 1; | ||||||
|  |  | ||||||
| #ifdef DEBUG_S3C_UDC | #ifdef DEBUG | ||||||
| 	printf("calling complete callback\n"); | 	printf("calling complete callback\n"); | ||||||
| 	{ | 	{ | ||||||
| 		int i, len = req->req.length; | 		int i, len = req->req.length; | ||||||
|   | |||||||
| @@ -53,7 +53,7 @@ static inline void s3c_udc_ep0_zlp(struct s3c_udc *dev) | |||||||
| 	writel(ep_ctrl|DEPCTL_EPENA|DEPCTL_CNAK, | 	writel(ep_ctrl|DEPCTL_EPENA|DEPCTL_CNAK, | ||||||
| 	       ®->in_endp[EP0_CON].diepctl); | 	       ®->in_endp[EP0_CON].diepctl); | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s:EP0 ZLP DIEPCTL0 = 0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, "%s:EP0 ZLP DIEPCTL0 = 0x%x\n", | ||||||
| 		__func__, readl(®->in_endp[EP0_CON].diepctl)); | 		__func__, readl(®->in_endp[EP0_CON].diepctl)); | ||||||
| 	dev->ep0state = WAIT_FOR_IN_COMPLETE; | 	dev->ep0state = WAIT_FOR_IN_COMPLETE; | ||||||
| } | } | ||||||
| @@ -62,7 +62,8 @@ void s3c_udc_pre_setup(void) | |||||||
| { | { | ||||||
| 	u32 ep_ctrl; | 	u32 ep_ctrl; | ||||||
|  |  | ||||||
| 	debug_cond(DEBUG_IN_EP, "%s : Prepare Setup packets.\n", __func__); | 	debug_cond(DEBUG_IN_EP, | ||||||
|  | 		   "%s : Prepare Setup packets.\n", __func__); | ||||||
|  |  | ||||||
| 	invalidate_dcache_range((unsigned long) usb_ctrl_dma_addr, | 	invalidate_dcache_range((unsigned long) usb_ctrl_dma_addr, | ||||||
| 				(unsigned long) usb_ctrl_dma_addr | 				(unsigned long) usb_ctrl_dma_addr | ||||||
| @@ -75,9 +76,9 @@ void s3c_udc_pre_setup(void) | |||||||
| 	ep_ctrl = readl(®->out_endp[EP0_CON].doepctl); | 	ep_ctrl = readl(®->out_endp[EP0_CON].doepctl); | ||||||
| 	writel(ep_ctrl|DEPCTL_EPENA, ®->out_endp[EP0_CON].doepctl); | 	writel(ep_ctrl|DEPCTL_EPENA, ®->out_endp[EP0_CON].doepctl); | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s:EP0 ZLP DIEPCTL0 = 0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, "%s:EP0 ZLP DIEPCTL0 = 0x%x\n", | ||||||
| 		__func__, readl(®->in_endp[EP0_CON].diepctl)); | 		__func__, readl(®->in_endp[EP0_CON].diepctl)); | ||||||
| 	DEBUG_EP0("%s:EP0 ZLP DOEPCTL0 = 0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, "%s:EP0 ZLP DOEPCTL0 = 0x%x\n", | ||||||
| 		__func__, readl(®->out_endp[EP0_CON].doepctl)); | 		__func__, readl(®->out_endp[EP0_CON].doepctl)); | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -86,9 +87,9 @@ static inline void s3c_ep0_complete_out(void) | |||||||
| { | { | ||||||
| 	u32 ep_ctrl; | 	u32 ep_ctrl; | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s:EP0 ZLP DIEPCTL0 = 0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, "%s:EP0 ZLP DIEPCTL0 = 0x%x\n", | ||||||
| 		__func__, readl(®->in_endp[EP0_CON].diepctl)); | 		__func__, readl(®->in_endp[EP0_CON].diepctl)); | ||||||
| 	DEBUG_EP0("%s:EP0 ZLP DOEPCTL0 = 0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, "%s:EP0 ZLP DOEPCTL0 = 0x%x\n", | ||||||
| 		__func__, readl(®->out_endp[EP0_CON].doepctl)); | 		__func__, readl(®->out_endp[EP0_CON].doepctl)); | ||||||
|  |  | ||||||
| 	debug_cond(DEBUG_IN_EP, | 	debug_cond(DEBUG_IN_EP, | ||||||
| @@ -106,9 +107,9 @@ static inline void s3c_ep0_complete_out(void) | |||||||
| 	writel(ep_ctrl|DEPCTL_EPENA|DEPCTL_CNAK, | 	writel(ep_ctrl|DEPCTL_EPENA|DEPCTL_CNAK, | ||||||
| 	       ®->out_endp[EP0_CON].doepctl); | 	       ®->out_endp[EP0_CON].doepctl); | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s:EP0 ZLP DIEPCTL0 = 0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, "%s:EP0 ZLP DIEPCTL0 = 0x%x\n", | ||||||
| 		__func__, readl(®->in_endp[EP0_CON].diepctl)); | 		__func__, readl(®->in_endp[EP0_CON].diepctl)); | ||||||
| 	DEBUG_EP0("%s:EP0 ZLP DOEPCTL0 = 0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, "%s:EP0 ZLP DOEPCTL0 = 0x%x\n", | ||||||
| 		__func__, readl(®->out_endp[EP0_CON].doepctl)); | 		__func__, readl(®->out_endp[EP0_CON].doepctl)); | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -145,14 +146,15 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req) | |||||||
| 	       ®->out_endp[ep_num].doeptsiz); | 	       ®->out_endp[ep_num].doeptsiz); | ||||||
| 	writel(DEPCTL_EPENA|DEPCTL_CNAK|ctrl, ®->out_endp[ep_num].doepctl); | 	writel(DEPCTL_EPENA|DEPCTL_CNAK|ctrl, ®->out_endp[ep_num].doepctl); | ||||||
|  |  | ||||||
| 	DEBUG_OUT_EP("%s: EP%d RX DMA start : DOEPDMA = 0x%x," | 	debug_cond(DEBUG_OUT_EP != 0, | ||||||
| 		     "DOEPTSIZ = 0x%x, DOEPCTL = 0x%x\n" | 		   "%s: EP%d RX DMA start : DOEPDMA = 0x%x," | ||||||
| 		     "\tbuf = 0x%p, pktcnt = %d, xfersize = %d\n", | 		   "DOEPTSIZ = 0x%x, DOEPCTL = 0x%x\n" | ||||||
| 		     __func__, ep_num, | 		   "\tbuf = 0x%p, pktcnt = %d, xfersize = %d\n", | ||||||
| 		     readl(®->out_endp[ep_num].doepdma), | 		   __func__, ep_num, | ||||||
| 		     readl(®->out_endp[ep_num].doeptsiz), | 		   readl(®->out_endp[ep_num].doepdma), | ||||||
| 		     readl(®->out_endp[ep_num].doepctl), | 		   readl(®->out_endp[ep_num].doeptsiz), | ||||||
| 		     buf, pktcnt, length); | 		   readl(®->out_endp[ep_num].doepctl), | ||||||
|  | 		   buf, pktcnt, length); | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -225,8 +227,9 @@ static void complete_rx(struct s3c_udc *dev, u8 ep_num) | |||||||
| 	u32 *p = the_controller->dma_buf[ep_index(ep)+1]; | 	u32 *p = the_controller->dma_buf[ep_index(ep)+1]; | ||||||
|  |  | ||||||
| 	if (list_empty(&ep->queue)) { | 	if (list_empty(&ep->queue)) { | ||||||
| 		DEBUG_OUT_EP("%s: RX DMA done : NULL REQ on OUT EP-%d\n", | 		debug_cond(DEBUG_OUT_EP != 0, | ||||||
| 					__func__, ep_num); | 			   "%s: RX DMA done : NULL REQ on OUT EP-%d\n", | ||||||
|  | 			   __func__, ep_num); | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| @@ -249,14 +252,15 @@ static void complete_rx(struct s3c_udc *dev, u8 ep_num) | |||||||
| 	req->req.actual += min(xfer_size, req->req.length - req->req.actual); | 	req->req.actual += min(xfer_size, req->req.length - req->req.actual); | ||||||
| 	is_short = (xfer_size < ep->ep.maxpacket); | 	is_short = (xfer_size < ep->ep.maxpacket); | ||||||
|  |  | ||||||
| 	DEBUG_OUT_EP("%s: RX DMA done : ep = %d, rx bytes = %d/%d, " | 	debug_cond(DEBUG_OUT_EP != 0, | ||||||
| 		     "is_short = %d, DOEPTSIZ = 0x%x, remained bytes = %d\n", | 		   "%s: RX DMA done : ep = %d, rx bytes = %d/%d, " | ||||||
| 			__func__, ep_num, req->req.actual, req->req.length, | 		   "is_short = %d, DOEPTSIZ = 0x%x, remained bytes = %d\n", | ||||||
| 			is_short, ep_tsr, xfer_size); | 		   __func__, ep_num, req->req.actual, req->req.length, | ||||||
|  | 		   is_short, ep_tsr, xfer_size); | ||||||
|  |  | ||||||
| 	if (is_short || req->req.actual == req->req.length) { | 	if (is_short || req->req.actual == req->req.length) { | ||||||
| 		if (ep_num == EP0_CON && dev->ep0state == DATA_STATE_RECV) { | 		if (ep_num == EP0_CON && dev->ep0state == DATA_STATE_RECV) { | ||||||
| 			DEBUG_OUT_EP("	=> Send ZLP\n"); | 			debug_cond(DEBUG_OUT_EP != 0, "	=> Send ZLP\n"); | ||||||
| 			s3c_udc_ep0_zlp(dev); | 			s3c_udc_ep0_zlp(dev); | ||||||
| 			/* packet will be completed in complete_tx() */ | 			/* packet will be completed in complete_tx() */ | ||||||
| 			dev->ep0state = WAIT_FOR_IN_COMPLETE; | 			dev->ep0state = WAIT_FOR_IN_COMPLETE; | ||||||
| @@ -266,8 +270,9 @@ static void complete_rx(struct s3c_udc *dev, u8 ep_num) | |||||||
| 			if (!list_empty(&ep->queue)) { | 			if (!list_empty(&ep->queue)) { | ||||||
| 				req = list_entry(ep->queue.next, | 				req = list_entry(ep->queue.next, | ||||||
| 					struct s3c_request, queue); | 					struct s3c_request, queue); | ||||||
| 				DEBUG_OUT_EP("%s: Next Rx request start...\n", | 				debug_cond(DEBUG_OUT_EP != 0, | ||||||
| 					 __func__); | 					   "%s: Next Rx request start...\n", | ||||||
|  | 					   __func__); | ||||||
| 				setdma_rx(ep, req); | 				setdma_rx(ep, req); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @@ -392,8 +397,9 @@ static void process_ep_in_intr(struct s3c_udc *dev) | |||||||
| 	while (ep_intr) { | 	while (ep_intr) { | ||||||
| 		if (ep_intr & DAINT_IN_EP_INT(1)) { | 		if (ep_intr & DAINT_IN_EP_INT(1)) { | ||||||
| 			ep_intr_status = readl(®->in_endp[ep_num].diepint); | 			ep_intr_status = readl(®->in_endp[ep_num].diepint); | ||||||
| 			debug_cond(DEBUG_IN_EP, "\tEP%d-IN : DIEPINT = 0x%x\n", | 			debug_cond(DEBUG_IN_EP, | ||||||
| 						ep_num, ep_intr_status); | 				   "\tEP%d-IN : DIEPINT = 0x%x\n", | ||||||
|  | 				   ep_num, ep_intr_status); | ||||||
|  |  | ||||||
| 			/* Interrupt Clear */ | 			/* Interrupt Clear */ | ||||||
| 			writel(ep_intr_status, ®->in_endp[ep_num].diepint); | 			writel(ep_intr_status, ®->in_endp[ep_num].diepint); | ||||||
| @@ -430,16 +436,18 @@ static void process_ep_out_intr(struct s3c_udc *dev) | |||||||
| 	u8 ep_num = 0; | 	u8 ep_num = 0; | ||||||
|  |  | ||||||
| 	ep_intr = readl(®->daint); | 	ep_intr = readl(®->daint); | ||||||
| 	DEBUG_OUT_EP("*** %s: EP OUT interrupt : DAINT = 0x%x\n", | 	debug_cond(DEBUG_OUT_EP != 0, | ||||||
| 				__func__, ep_intr); | 		   "*** %s: EP OUT interrupt : DAINT = 0x%x\n", | ||||||
|  | 		   __func__, ep_intr); | ||||||
|  |  | ||||||
| 	ep_intr = (ep_intr >> DAINT_OUT_BIT) & DAINT_MASK; | 	ep_intr = (ep_intr >> DAINT_OUT_BIT) & DAINT_MASK; | ||||||
|  |  | ||||||
| 	while (ep_intr) { | 	while (ep_intr) { | ||||||
| 		if (ep_intr & 0x1) { | 		if (ep_intr & 0x1) { | ||||||
| 			ep_intr_status = readl(®->out_endp[ep_num].doepint); | 			ep_intr_status = readl(®->out_endp[ep_num].doepint); | ||||||
| 			DEBUG_OUT_EP("\tEP%d-OUT : DOEPINT = 0x%x\n", | 			debug_cond(DEBUG_OUT_EP != 0, | ||||||
| 						ep_num, ep_intr_status); | 				   "\tEP%d-OUT : DOEPINT = 0x%x\n", | ||||||
|  | 				   ep_num, ep_intr_status); | ||||||
|  |  | ||||||
| 			/* Interrupt Clear */ | 			/* Interrupt Clear */ | ||||||
| 			writel(ep_intr_status, ®->out_endp[ep_num].doepint); | 			writel(ep_intr_status, ®->out_endp[ep_num].doepint); | ||||||
| @@ -457,7 +465,8 @@ static void process_ep_out_intr(struct s3c_udc *dev) | |||||||
|  |  | ||||||
| 				if (ep_intr_status & | 				if (ep_intr_status & | ||||||
| 				    CTRL_OUT_EP_SETUP_PHASE_DONE) { | 				    CTRL_OUT_EP_SETUP_PHASE_DONE) { | ||||||
| 					DEBUG_OUT_EP("SETUP packet arrived\n"); | 					debug_cond(DEBUG_OUT_EP != 0, | ||||||
|  | 						   "SETUP packet arrived\n"); | ||||||
| 					s3c_handle_ep0(dev); | 					s3c_handle_ep0(dev); | ||||||
| 				} | 				} | ||||||
| 			} else { | 			} else { | ||||||
| @@ -503,7 +512,8 @@ static int s3c_udc_irq(int irq, void *_dev) | |||||||
| 		usb_status = (readl(®->dsts) & 0x6); | 		usb_status = (readl(®->dsts) & 0x6); | ||||||
|  |  | ||||||
| 		if (usb_status & (USB_FULL_30_60MHZ | USB_FULL_48MHZ)) { | 		if (usb_status & (USB_FULL_30_60MHZ | USB_FULL_48MHZ)) { | ||||||
| 			debug_cond(DEBUG_ISR, "\t\tFull Speed Detection\n"); | 			debug_cond(DEBUG_ISR, | ||||||
|  | 				   "\t\tFull Speed Detection\n"); | ||||||
| 			set_max_pktsize(dev, USB_SPEED_FULL); | 			set_max_pktsize(dev, USB_SPEED_FULL); | ||||||
|  |  | ||||||
| 		} else { | 		} else { | ||||||
| @@ -571,7 +581,8 @@ static int s3c_udc_irq(int irq, void *_dev) | |||||||
|  |  | ||||||
| 		} else { | 		} else { | ||||||
| 			reset_available = 1; | 			reset_available = 1; | ||||||
| 			debug_cond(DEBUG_ISR, "\t\tRESET handling skipped\n"); | 			debug_cond(DEBUG_ISR, | ||||||
|  | 				   "\t\tRESET handling skipped\n"); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -635,7 +646,7 @@ static int s3c_queue(struct usb_ep *_ep, struct usb_request *_req, | |||||||
| 		_req, _req->length, _req->buf, | 		_req, _req->length, _req->buf, | ||||||
| 		list_empty(&ep->queue), ep->stopped); | 		list_empty(&ep->queue), ep->stopped); | ||||||
|  |  | ||||||
| #ifdef DEBUG_S3C_UDC | #ifdef DEBUG | ||||||
| 	{ | 	{ | ||||||
| 		int i, len = _req->length; | 		int i, len = _req->length; | ||||||
|  |  | ||||||
| @@ -662,14 +673,15 @@ static int s3c_queue(struct usb_ep *_ep, struct usb_request *_req, | |||||||
| 		} else if (ep_is_in(ep)) { | 		} else if (ep_is_in(ep)) { | ||||||
| 			gintsts = readl(®->gintsts); | 			gintsts = readl(®->gintsts); | ||||||
| 			debug_cond(DEBUG_IN_EP, | 			debug_cond(DEBUG_IN_EP, | ||||||
| 				"%s: ep_is_in, S3C_UDC_OTG_GINTSTS=0x%x\n", | 				   "%s: ep_is_in, S3C_UDC_OTG_GINTSTS=0x%x\n", | ||||||
| 				__func__, gintsts); | 				   __func__, gintsts); | ||||||
|  |  | ||||||
| 			setdma_tx(ep, req); | 			setdma_tx(ep, req); | ||||||
| 		} else { | 		} else { | ||||||
| 			gintsts = readl(®->gintsts); | 			gintsts = readl(®->gintsts); | ||||||
| 			DEBUG_OUT_EP("%s:ep_is_out, S3C_UDC_OTG_GINTSTS=0x%x\n", | 			debug_cond(DEBUG_OUT_EP != 0, | ||||||
| 				__func__, gintsts); | 				   "%s:ep_is_out, S3C_UDC_OTG_GINTSTS=0x%x\n", | ||||||
|  | 				   __func__, gintsts); | ||||||
|  |  | ||||||
| 			setdma_rx(ep, req); | 			setdma_rx(ep, req); | ||||||
| 		} | 		} | ||||||
| @@ -697,7 +709,7 @@ static int write_fifo_ep0(struct s3c_ep *ep, struct s3c_request *req) | |||||||
|  |  | ||||||
| 	max = ep_maxpacket(ep); | 	max = ep_maxpacket(ep); | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s: max = %d\n", __func__, max); | 	debug_cond(DEBUG_EP0 != 0, "%s: max = %d\n", __func__, max); | ||||||
|  |  | ||||||
| 	count = setdma_tx(ep, req); | 	count = setdma_tx(ep, req); | ||||||
|  |  | ||||||
| @@ -712,10 +724,11 @@ static int write_fifo_ep0(struct s3c_ep *ep, struct s3c_request *req) | |||||||
| 			is_last = 1; | 			is_last = 1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s: wrote %s %d bytes%s %d left %p\n", __func__, | 	debug_cond(DEBUG_EP0 != 0, | ||||||
| 		  ep->ep.name, count, | 		   "%s: wrote %s %d bytes%s %d left %p\n", __func__, | ||||||
| 		  is_last ? "/L" : "", | 		   ep->ep.name, count, | ||||||
| 		  req->req.length - req->req.actual - count, req); | 		   is_last ? "/L" : "", | ||||||
|  | 		   req->req.length - req->req.actual - count, req); | ||||||
|  |  | ||||||
| 	/* requests complete when all IN data is in the FIFO */ | 	/* requests complete when all IN data is in the FIFO */ | ||||||
| 	if (is_last) { | 	if (is_last) { | ||||||
| @@ -736,8 +749,9 @@ int s3c_fifo_read(struct s3c_ep *ep, u32 *cp, int max) | |||||||
| 				(unsigned long) ep->dev->dma_buf[ep_index(ep)] | 				(unsigned long) ep->dev->dma_buf[ep_index(ep)] | ||||||
| 				+ DMA_BUFFER_SIZE); | 				+ DMA_BUFFER_SIZE); | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s: bytes=%d, ep_index=%d %p\n", __func__, | 	debug_cond(DEBUG_EP0 != 0, | ||||||
| 		  bytes, ep_index(ep), ep->dev->dma_buf[ep_index(ep)]); | 		   "%s: bytes=%d, ep_index=%d %p\n", __func__, | ||||||
|  | 		   bytes, ep_index(ep), ep->dev->dma_buf[ep_index(ep)]); | ||||||
|  |  | ||||||
| 	return bytes; | 	return bytes; | ||||||
| } | } | ||||||
| @@ -756,8 +770,9 @@ static void udc_set_address(struct s3c_udc *dev, unsigned char address) | |||||||
|  |  | ||||||
| 	s3c_udc_ep0_zlp(dev); | 	s3c_udc_ep0_zlp(dev); | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s: USB OTG 2.0 Device address=%d, DCFG=0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, | ||||||
| 		__func__, address, readl(®->dcfg)); | 		   "%s: USB OTG 2.0 Device address=%d, DCFG=0x%x\n", | ||||||
|  | 		   __func__, address, readl(®->dcfg)); | ||||||
|  |  | ||||||
| 	dev->usb_address = address; | 	dev->usb_address = address; | ||||||
| } | } | ||||||
| @@ -778,8 +793,9 @@ static inline void s3c_udc_ep0_set_stall(struct s3c_ep *ep) | |||||||
|  |  | ||||||
| 	writel(ep_ctrl, ®->in_endp[EP0_CON].diepctl); | 	writel(ep_ctrl, ®->in_endp[EP0_CON].diepctl); | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s: set ep%d stall, DIEPCTL0 = 0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, | ||||||
| 		__func__, ep_index(ep), ®->in_endp[EP0_CON].diepctl); | 		   "%s: set ep%d stall, DIEPCTL0 = 0x%p\n", | ||||||
|  | 		   __func__, ep_index(ep), ®->in_endp[EP0_CON].diepctl); | ||||||
| 	/* | 	/* | ||||||
| 	 * The application can only set this bit, and the core clears it, | 	 * The application can only set this bit, and the core clears it, | ||||||
| 	 * when a SETUP token is received for this endpoint | 	 * when a SETUP token is received for this endpoint | ||||||
| @@ -803,8 +819,9 @@ static void s3c_ep0_read(struct s3c_udc *dev) | |||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s: req = %p, req.length = 0x%x, req.actual = 0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, | ||||||
| 		__func__, req, req->req.length, req->req.actual); | 		   "%s: req = %p, req.length = 0x%x, req.actual = 0x%x\n", | ||||||
|  | 		   __func__, req, req->req.length, req->req.actual); | ||||||
|  |  | ||||||
| 	if (req->req.length == 0) { | 	if (req->req.length == 0) { | ||||||
| 		/* zlp for Set_configuration, Set_interface, | 		/* zlp for Set_configuration, Set_interface, | ||||||
| @@ -813,8 +830,9 @@ static void s3c_ep0_read(struct s3c_udc *dev) | |||||||
| 		ep->len = 0; | 		ep->len = 0; | ||||||
| 		s3c_udc_ep0_zlp(dev); | 		s3c_udc_ep0_zlp(dev); | ||||||
|  |  | ||||||
| 		DEBUG_EP0("%s: req.length = 0, bRequest = %d\n", | 		debug_cond(DEBUG_EP0 != 0, | ||||||
| 			  __func__, usb_ctrl->bRequest); | 			   "%s: req.length = 0, bRequest = %d\n", | ||||||
|  | 			   __func__, usb_ctrl->bRequest); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -836,12 +854,13 @@ static int s3c_ep0_write(struct s3c_udc *dev) | |||||||
| 		req = list_entry(ep->queue.next, struct s3c_request, queue); | 		req = list_entry(ep->queue.next, struct s3c_request, queue); | ||||||
|  |  | ||||||
| 	if (!req) { | 	if (!req) { | ||||||
| 		DEBUG_EP0("%s: NULL REQ\n", __func__); | 		debug_cond(DEBUG_EP0 != 0, "%s: NULL REQ\n", __func__); | ||||||
| 		return 0; | 		return 0; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	DEBUG_EP0("%s: req = %p, req.length = 0x%x, req.actual = 0x%x\n", | 	debug_cond(DEBUG_EP0 != 0, | ||||||
| 		__func__, req, req->req.length, req->req.actual); | 		   "%s: req = %p, req.length = 0x%x, req.actual = 0x%x\n", | ||||||
|  | 		   __func__, req, req->req.length, req->req.actual); | ||||||
|  |  | ||||||
| 	if (req->req.length - req->req.actual == ep0_fifo_size) { | 	if (req->req.length - req->req.actual == ep0_fifo_size) { | ||||||
| 		/* Next write will end with the packet size, */ | 		/* Next write will end with the packet size, */ | ||||||
| @@ -854,11 +873,13 @@ static int s3c_ep0_write(struct s3c_udc *dev) | |||||||
| 	if ((ret == 1) && !need_zlp) { | 	if ((ret == 1) && !need_zlp) { | ||||||
| 		/* Last packet */ | 		/* Last packet */ | ||||||
| 		dev->ep0state = WAIT_FOR_COMPLETE; | 		dev->ep0state = WAIT_FOR_COMPLETE; | ||||||
| 		DEBUG_EP0("%s: finished, waiting for status\n", __func__); | 		debug_cond(DEBUG_EP0 != 0, | ||||||
|  | 			   "%s: finished, waiting for status\n", __func__); | ||||||
|  |  | ||||||
| 	} else { | 	} else { | ||||||
| 		dev->ep0state = DATA_STATE_XMIT; | 		dev->ep0state = DATA_STATE_XMIT; | ||||||
| 		DEBUG_EP0("%s: not finished\n", __func__); | 		debug_cond(DEBUG_EP0 != 0, | ||||||
|  | 			   "%s: not finished\n", __func__); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return 1; | 	return 1; | ||||||
| @@ -873,30 +894,35 @@ int s3c_udc_get_status(struct s3c_udc *dev, | |||||||
| 	u32 ep_ctrl; | 	u32 ep_ctrl; | ||||||
| 	u32 *p = the_controller->dma_buf[1]; | 	u32 *p = the_controller->dma_buf[1]; | ||||||
|  |  | ||||||
| 	DEBUG_SETUP("%s: *** USB_REQ_GET_STATUS\n", __func__); | 	debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 		   "%s: *** USB_REQ_GET_STATUS\n", __func__); | ||||||
| 	printf("crq->brequest:0x%x\n", crq->bRequestType & USB_RECIP_MASK); | 	printf("crq->brequest:0x%x\n", crq->bRequestType & USB_RECIP_MASK); | ||||||
| 	switch (crq->bRequestType & USB_RECIP_MASK) { | 	switch (crq->bRequestType & USB_RECIP_MASK) { | ||||||
| 	case USB_RECIP_INTERFACE: | 	case USB_RECIP_INTERFACE: | ||||||
| 		g_status = 0; | 		g_status = 0; | ||||||
| 		DEBUG_SETUP("\tGET_STATUS:USB_RECIP_INTERFACE, g_stauts = %d\n", | 		debug_cond(DEBUG_SETUP != 0, | ||||||
| 			    g_status); | 			   "\tGET_STATUS:USB_RECIP_INTERFACE, g_stauts = %d\n", | ||||||
|  | 			   g_status); | ||||||
| 		break; | 		break; | ||||||
|  |  | ||||||
| 	case USB_RECIP_DEVICE: | 	case USB_RECIP_DEVICE: | ||||||
| 		g_status = 0x1; /* Self powered */ | 		g_status = 0x1; /* Self powered */ | ||||||
| 		DEBUG_SETUP("\tGET_STATUS: USB_RECIP_DEVICE, g_stauts = %d\n", | 		debug_cond(DEBUG_SETUP != 0, | ||||||
| 			    g_status); | 			   "\tGET_STATUS: USB_RECIP_DEVICE, g_stauts = %d\n", | ||||||
|  | 			   g_status); | ||||||
| 		break; | 		break; | ||||||
|  |  | ||||||
| 	case USB_RECIP_ENDPOINT: | 	case USB_RECIP_ENDPOINT: | ||||||
| 		if (crq->wLength > 2) { | 		if (crq->wLength > 2) { | ||||||
| 			DEBUG_SETUP("\tGET_STATUS:Not support EP or wLength\n"); | 			debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 				   "\tGET_STATUS:Not support EP or wLength\n"); | ||||||
| 			return 1; | 			return 1; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		g_status = dev->ep[ep_num].stopped; | 		g_status = dev->ep[ep_num].stopped; | ||||||
| 		DEBUG_SETUP("\tGET_STATUS: USB_RECIP_ENDPOINT, g_stauts = %d\n", | 		debug_cond(DEBUG_SETUP != 0, | ||||||
| 			    g_status); | 			   "\tGET_STATUS: USB_RECIP_ENDPOINT, g_stauts = %d\n", | ||||||
|  | 			   g_status); | ||||||
|  |  | ||||||
| 		break; | 		break; | ||||||
|  |  | ||||||
| @@ -1134,11 +1160,13 @@ static int s3c_udc_clear_feature(struct usb_ep *_ep) | |||||||
| 	ep_num = ep_index(ep); | 	ep_num = ep_index(ep); | ||||||
|  |  | ||||||
| 	dev = ep->dev; | 	dev = ep->dev; | ||||||
| 	DEBUG_SETUP("%s: ep_num = %d, is_in = %d, clear_feature_flag = %d\n", | 	debug_cond(DEBUG_SETUP != 0, | ||||||
| 		__func__, ep_num, ep_is_in(ep), clear_feature_flag); | 		   "%s: ep_num = %d, is_in = %d, clear_feature_flag = %d\n", | ||||||
|  | 		   __func__, ep_num, ep_is_in(ep), clear_feature_flag); | ||||||
|  |  | ||||||
| 	if (usb_ctrl->wLength != 0) { | 	if (usb_ctrl->wLength != 0) { | ||||||
| 		DEBUG_SETUP("\tCLEAR_FEATURE: wLength is not zero.....\n"); | 		debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 			   "\tCLEAR_FEATURE: wLength is not zero.....\n"); | ||||||
| 		return 1; | 		return 1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -1146,11 +1174,13 @@ static int s3c_udc_clear_feature(struct usb_ep *_ep) | |||||||
| 	case USB_RECIP_DEVICE: | 	case USB_RECIP_DEVICE: | ||||||
| 		switch (usb_ctrl->wValue) { | 		switch (usb_ctrl->wValue) { | ||||||
| 		case USB_DEVICE_REMOTE_WAKEUP: | 		case USB_DEVICE_REMOTE_WAKEUP: | ||||||
| 			DEBUG_SETUP("\tOFF:USB_DEVICE_REMOTE_WAKEUP\n"); | 			debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 				   "\tOFF:USB_DEVICE_REMOTE_WAKEUP\n"); | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		case USB_DEVICE_TEST_MODE: | 		case USB_DEVICE_TEST_MODE: | ||||||
| 			DEBUG_SETUP("\tCLEAR_FEATURE: USB_DEVICE_TEST_MODE\n"); | 			debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 				   "\tCLEAR_FEATURE: USB_DEVICE_TEST_MODE\n"); | ||||||
| 			/** @todo Add CLEAR_FEATURE for TEST modes. */ | 			/** @todo Add CLEAR_FEATURE for TEST modes. */ | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| @@ -1159,8 +1189,9 @@ static int s3c_udc_clear_feature(struct usb_ep *_ep) | |||||||
| 		break; | 		break; | ||||||
|  |  | ||||||
| 	case USB_RECIP_ENDPOINT: | 	case USB_RECIP_ENDPOINT: | ||||||
| 		DEBUG_SETUP("\tCLEAR_FEATURE:USB_RECIP_ENDPOINT, wValue = %d\n", | 		debug_cond(DEBUG_SETUP != 0, | ||||||
| 				usb_ctrl->wValue); | 			   "\tCLEAR_FEATURE:USB_RECIP_ENDPOINT, wValue = %d\n", | ||||||
|  | 			   usb_ctrl->wValue); | ||||||
|  |  | ||||||
| 		if (usb_ctrl->wValue == USB_ENDPOINT_HALT) { | 		if (usb_ctrl->wValue == USB_ENDPOINT_HALT) { | ||||||
| 			if (ep_num == 0) { | 			if (ep_num == 0) { | ||||||
| @@ -1193,11 +1224,13 @@ static int s3c_udc_set_feature(struct usb_ep *_ep) | |||||||
| 	ep_num = ep_index(ep); | 	ep_num = ep_index(ep); | ||||||
| 	dev = ep->dev; | 	dev = ep->dev; | ||||||
|  |  | ||||||
| 	DEBUG_SETUP("%s: *** USB_REQ_SET_FEATURE , ep_num = %d\n", | 	debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 		   "%s: *** USB_REQ_SET_FEATURE , ep_num = %d\n", | ||||||
| 		    __func__, ep_num); | 		    __func__, ep_num); | ||||||
|  |  | ||||||
| 	if (usb_ctrl->wLength != 0) { | 	if (usb_ctrl->wLength != 0) { | ||||||
| 		DEBUG_SETUP("\tSET_FEATURE: wLength is not zero.....\n"); | 		debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 			   "\tSET_FEATURE: wLength is not zero.....\n"); | ||||||
| 		return 1; | 		return 1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -1205,20 +1238,24 @@ static int s3c_udc_set_feature(struct usb_ep *_ep) | |||||||
| 	case USB_RECIP_DEVICE: | 	case USB_RECIP_DEVICE: | ||||||
| 		switch (usb_ctrl->wValue) { | 		switch (usb_ctrl->wValue) { | ||||||
| 		case USB_DEVICE_REMOTE_WAKEUP: | 		case USB_DEVICE_REMOTE_WAKEUP: | ||||||
| 			DEBUG_SETUP("\tSET_FEATURE:USB_DEVICE_REMOTE_WAKEUP\n"); | 			debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 				   "\tSET_FEATURE:USB_DEVICE_REMOTE_WAKEUP\n"); | ||||||
| 			break; | 			break; | ||||||
| 		case USB_DEVICE_B_HNP_ENABLE: | 		case USB_DEVICE_B_HNP_ENABLE: | ||||||
| 			DEBUG_SETUP("\tSET_FEATURE: USB_DEVICE_B_HNP_ENABLE\n"); | 			debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 				   "\tSET_FEATURE: USB_DEVICE_B_HNP_ENABLE\n"); | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		case USB_DEVICE_A_HNP_SUPPORT: | 		case USB_DEVICE_A_HNP_SUPPORT: | ||||||
| 			/* RH port supports HNP */ | 			/* RH port supports HNP */ | ||||||
| 			DEBUG_SETUP("\tSET_FEATURE:USB_DEVICE_A_HNP_SUPPORT\n"); | 			debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 				   "\tSET_FEATURE:USB_DEVICE_A_HNP_SUPPORT\n"); | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		case USB_DEVICE_A_ALT_HNP_SUPPORT: | 		case USB_DEVICE_A_ALT_HNP_SUPPORT: | ||||||
| 			/* other RH port does */ | 			/* other RH port does */ | ||||||
| 			DEBUG_SETUP("\tSET: USB_DEVICE_A_ALT_HNP_SUPPORT\n"); | 			debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 				   "\tSET: USB_DEVICE_A_ALT_HNP_SUPPORT\n"); | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -1226,11 +1263,13 @@ static int s3c_udc_set_feature(struct usb_ep *_ep) | |||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	case USB_RECIP_INTERFACE: | 	case USB_RECIP_INTERFACE: | ||||||
| 		DEBUG_SETUP("\tSET_FEATURE: USB_RECIP_INTERFACE\n"); | 		debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 			   "\tSET_FEATURE: USB_RECIP_INTERFACE\n"); | ||||||
| 		break; | 		break; | ||||||
|  |  | ||||||
| 	case USB_RECIP_ENDPOINT: | 	case USB_RECIP_ENDPOINT: | ||||||
| 		DEBUG_SETUP("\tSET_FEATURE: USB_RECIP_ENDPOINT\n"); | 		debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 			   "\tSET_FEATURE: USB_RECIP_ENDPOINT\n"); | ||||||
| 		if (usb_ctrl->wValue == USB_ENDPOINT_HALT) { | 		if (usb_ctrl->wValue == USB_ENDPOINT_HALT) { | ||||||
| 			if (ep_num == 0) { | 			if (ep_num == 0) { | ||||||
| 				s3c_udc_ep0_set_stall(ep); | 				s3c_udc_ep0_set_stall(ep); | ||||||
| @@ -1262,14 +1301,15 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
| 	/* read control req from fifo (8 bytes) */ | 	/* read control req from fifo (8 bytes) */ | ||||||
| 	s3c_fifo_read(ep, (u32 *)usb_ctrl, 8); | 	s3c_fifo_read(ep, (u32 *)usb_ctrl, 8); | ||||||
|  |  | ||||||
| 	DEBUG_SETUP("%s: bRequestType = 0x%x(%s), bRequest = 0x%x" | 	debug_cond(DEBUG_SETUP != 0, | ||||||
| 		    "\twLength = 0x%x, wValue = 0x%x, wIndex= 0x%x\n", | 		   "%s: bRequestType = 0x%x(%s), bRequest = 0x%x" | ||||||
| 		    __func__, usb_ctrl->bRequestType, | 		   "\twLength = 0x%x, wValue = 0x%x, wIndex= 0x%x\n", | ||||||
| 		    (usb_ctrl->bRequestType & USB_DIR_IN) ? "IN" : "OUT", | 		   __func__, usb_ctrl->bRequestType, | ||||||
| 		    usb_ctrl->bRequest, | 		   (usb_ctrl->bRequestType & USB_DIR_IN) ? "IN" : "OUT", | ||||||
| 		    usb_ctrl->wLength, usb_ctrl->wValue, usb_ctrl->wIndex); | 		   usb_ctrl->bRequest, | ||||||
|  | 		   usb_ctrl->wLength, usb_ctrl->wValue, usb_ctrl->wIndex); | ||||||
|  |  | ||||||
| #ifdef DEBUG_S3C_UDC | #ifdef DEBUG | ||||||
| 	{ | 	{ | ||||||
| 		int i, len = sizeof(*usb_ctrl); | 		int i, len = sizeof(*usb_ctrl); | ||||||
| 		char *p = (char *)usb_ctrl; | 		char *p = (char *)usb_ctrl; | ||||||
| @@ -1286,10 +1326,12 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
|  |  | ||||||
| 	if (usb_ctrl->bRequest == GET_MAX_LUN_REQUEST && | 	if (usb_ctrl->bRequest == GET_MAX_LUN_REQUEST && | ||||||
| 	    usb_ctrl->wLength != 1) { | 	    usb_ctrl->wLength != 1) { | ||||||
| 		DEBUG_SETUP("\t%s:GET_MAX_LUN_REQUEST:invalid", | 		debug_cond(DEBUG_SETUP != 0, | ||||||
| 			      __func__); | 			   "\t%s:GET_MAX_LUN_REQUEST:invalid", | ||||||
| 		DEBUG_SETUP("wLength = %d, setup returned\n", | 			   __func__); | ||||||
| 			    usb_ctrl->wLength); | 		debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 			   "wLength = %d, setup returned\n", | ||||||
|  | 			   usb_ctrl->wLength); | ||||||
|  |  | ||||||
| 		s3c_udc_ep0_set_stall(ep); | 		s3c_udc_ep0_set_stall(ep); | ||||||
| 		dev->ep0state = WAIT_FOR_SETUP; | 		dev->ep0state = WAIT_FOR_SETUP; | ||||||
| @@ -1298,8 +1340,9 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
| 	} else if (usb_ctrl->bRequest == BOT_RESET_REQUEST && | 	} else if (usb_ctrl->bRequest == BOT_RESET_REQUEST && | ||||||
| 		 usb_ctrl->wLength != 0) { | 		 usb_ctrl->wLength != 0) { | ||||||
| 		/* Bulk-Only *mass storge reset of class-specific request */ | 		/* Bulk-Only *mass storge reset of class-specific request */ | ||||||
| 		DEBUG_SETUP("%s:BOT Rest:invalid wLength =%d, setup returned\n", | 		debug_cond(DEBUG_SETUP != 0, | ||||||
| 			    __func__, usb_ctrl->wLength); | 			   "%s:BOT Rest:invalid wLength =%d, setup returned\n", | ||||||
|  | 			   __func__, usb_ctrl->wLength); | ||||||
|  |  | ||||||
| 		s3c_udc_ep0_set_stall(ep); | 		s3c_udc_ep0_set_stall(ep); | ||||||
| 		dev->ep0state = WAIT_FOR_SETUP; | 		dev->ep0state = WAIT_FOR_SETUP; | ||||||
| @@ -1323,8 +1366,9 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
| 	if (dev->req_std) { | 	if (dev->req_std) { | ||||||
| 		switch (usb_ctrl->bRequest) { | 		switch (usb_ctrl->bRequest) { | ||||||
| 		case USB_REQ_SET_ADDRESS: | 		case USB_REQ_SET_ADDRESS: | ||||||
| 		DEBUG_SETUP("%s: *** USB_REQ_SET_ADDRESS (%d)\n", | 		debug_cond(DEBUG_SETUP != 0, | ||||||
| 				__func__, usb_ctrl->wValue); | 			   "%s: *** USB_REQ_SET_ADDRESS (%d)\n", | ||||||
|  | 			   __func__, usb_ctrl->wValue); | ||||||
| 			if (usb_ctrl->bRequestType | 			if (usb_ctrl->bRequestType | ||||||
| 				!= (USB_TYPE_STANDARD | USB_RECIP_DEVICE)) | 				!= (USB_TYPE_STANDARD | USB_RECIP_DEVICE)) | ||||||
| 				break; | 				break; | ||||||
| @@ -1333,9 +1377,11 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
| 			return; | 			return; | ||||||
|  |  | ||||||
| 		case USB_REQ_SET_CONFIGURATION: | 		case USB_REQ_SET_CONFIGURATION: | ||||||
| 			DEBUG_SETUP("=====================================\n"); | 			debug_cond(DEBUG_SETUP != 0, | ||||||
| 			DEBUG_SETUP("%s: USB_REQ_SET_CONFIGURATION (%d)\n", | 				   "=====================================\n"); | ||||||
| 					__func__, usb_ctrl->wValue); | 			debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 				   "%s: USB_REQ_SET_CONFIGURATION (%d)\n", | ||||||
|  | 				   __func__, usb_ctrl->wValue); | ||||||
|  |  | ||||||
| 			if (usb_ctrl->bRequestType == USB_RECIP_DEVICE) | 			if (usb_ctrl->bRequestType == USB_RECIP_DEVICE) | ||||||
| 				reset_available = 1; | 				reset_available = 1; | ||||||
| @@ -1343,13 +1389,15 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		case USB_REQ_GET_DESCRIPTOR: | 		case USB_REQ_GET_DESCRIPTOR: | ||||||
| 			DEBUG_SETUP("%s: *** USB_REQ_GET_DESCRIPTOR\n", | 			debug_cond(DEBUG_SETUP != 0, | ||||||
| 				    __func__); | 				   "%s: *** USB_REQ_GET_DESCRIPTOR\n", | ||||||
|  | 				   __func__); | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		case USB_REQ_SET_INTERFACE: | 		case USB_REQ_SET_INTERFACE: | ||||||
| 			DEBUG_SETUP("%s: *** USB_REQ_SET_INTERFACE (%d)\n", | 			debug_cond(DEBUG_SETUP != 0, | ||||||
| 					__func__, usb_ctrl->wValue); | 				   "%s: *** USB_REQ_SET_INTERFACE (%d)\n", | ||||||
|  | 				   __func__, usb_ctrl->wValue); | ||||||
|  |  | ||||||
| 			if (usb_ctrl->bRequestType == USB_RECIP_INTERFACE) | 			if (usb_ctrl->bRequestType == USB_RECIP_INTERFACE) | ||||||
| 				reset_available = 1; | 				reset_available = 1; | ||||||
| @@ -1357,8 +1405,9 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		case USB_REQ_GET_CONFIGURATION: | 		case USB_REQ_GET_CONFIGURATION: | ||||||
| 			DEBUG_SETUP("%s: *** USB_REQ_GET_CONFIGURATION\n", | 			debug_cond(DEBUG_SETUP != 0, | ||||||
| 				    __func__); | 				   "%s: *** USB_REQ_GET_CONFIGURATION\n", | ||||||
|  | 				   __func__); | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		case USB_REQ_GET_STATUS: | 		case USB_REQ_GET_STATUS: | ||||||
| @@ -1384,8 +1433,9 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		default: | 		default: | ||||||
| 			DEBUG_SETUP("%s: *** Default of usb_ctrl->bRequest=0x%x" | 			debug_cond(DEBUG_SETUP != 0, | ||||||
| 				"happened.\n", __func__, usb_ctrl->bRequest); | 				   "%s: *** Default of usb_ctrl->bRequest=0x%x" | ||||||
|  | 				   "happened.\n", __func__, usb_ctrl->bRequest); | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -1394,7 +1444,8 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
| 	if (likely(dev->driver)) { | 	if (likely(dev->driver)) { | ||||||
| 		/* device-2-host (IN) or no data setup command, | 		/* device-2-host (IN) or no data setup command, | ||||||
| 		 * process immediately */ | 		 * process immediately */ | ||||||
| 		DEBUG_SETUP("%s:usb_ctrlreq will be passed to fsg_setup()\n", | 		debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 			   "%s:usb_ctrlreq will be passed to fsg_setup()\n", | ||||||
| 			    __func__); | 			    __func__); | ||||||
|  |  | ||||||
| 		spin_unlock(&dev->lock); | 		spin_unlock(&dev->lock); | ||||||
| @@ -1406,17 +1457,20 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
| 			s3c_udc_ep0_set_stall(ep); | 			s3c_udc_ep0_set_stall(ep); | ||||||
| 			dev->ep0state = WAIT_FOR_SETUP; | 			dev->ep0state = WAIT_FOR_SETUP; | ||||||
|  |  | ||||||
| 			DEBUG_SETUP("\tdev->driver->setup failed (%d)," | 			debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 				   "\tdev->driver->setup failed (%d)," | ||||||
| 				    " bRequest = %d\n", | 				    " bRequest = %d\n", | ||||||
| 				i, usb_ctrl->bRequest); | 				i, usb_ctrl->bRequest); | ||||||
|  |  | ||||||
|  |  | ||||||
| 		} else if (dev->req_pending) { | 		} else if (dev->req_pending) { | ||||||
| 			dev->req_pending = 0; | 			dev->req_pending = 0; | ||||||
| 			DEBUG_SETUP("\tdev->req_pending...\n"); | 			debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 				   "\tdev->req_pending...\n"); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		DEBUG_SETUP("\tep0state = %s\n", state_names[dev->ep0state]); | 		debug_cond(DEBUG_SETUP != 0, | ||||||
|  | 			   "\tep0state = %s\n", state_names[dev->ep0state]); | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -1427,18 +1481,21 @@ void s3c_ep0_setup(struct s3c_udc *dev) | |||||||
| static void s3c_handle_ep0(struct s3c_udc *dev) | static void s3c_handle_ep0(struct s3c_udc *dev) | ||||||
| { | { | ||||||
| 	if (dev->ep0state == WAIT_FOR_SETUP) { | 	if (dev->ep0state == WAIT_FOR_SETUP) { | ||||||
| 		DEBUG_OUT_EP("%s: WAIT_FOR_SETUP\n", __func__); | 		debug_cond(DEBUG_OUT_EP != 0, | ||||||
|  | 			   "%s: WAIT_FOR_SETUP\n", __func__); | ||||||
| 		s3c_ep0_setup(dev); | 		s3c_ep0_setup(dev); | ||||||
|  |  | ||||||
| 	} else { | 	} else { | ||||||
| 		DEBUG_OUT_EP("%s: strange state!!(state = %s)\n", | 		debug_cond(DEBUG_OUT_EP != 0, | ||||||
|  | 			   "%s: strange state!!(state = %s)\n", | ||||||
| 			__func__, state_names[dev->ep0state]); | 			__func__, state_names[dev->ep0state]); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| static void s3c_ep0_kick(struct s3c_udc *dev, struct s3c_ep *ep) | static void s3c_ep0_kick(struct s3c_udc *dev, struct s3c_ep *ep) | ||||||
| { | { | ||||||
| 	DEBUG_EP0("%s: ep_is_in = %d\n", __func__, ep_is_in(ep)); | 	debug_cond(DEBUG_EP0 != 0, | ||||||
|  | 		   "%s: ep_is_in = %d\n", __func__, ep_is_in(ep)); | ||||||
| 	if (ep_is_in(ep)) { | 	if (ep_is_in(ep)) { | ||||||
| 		dev->ep0state = DATA_STATE_XMIT; | 		dev->ep0state = DATA_STATE_XMIT; | ||||||
| 		s3c_ep0_write(dev); | 		s3c_ep0_write(dev); | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ | |||||||
| #include <common.h> | #include <common.h> | ||||||
| #include <asm/errno.h> | #include <asm/errno.h> | ||||||
| #include <linux/usb/ch9.h> | #include <linux/usb/ch9.h> | ||||||
|  | #include <usbdescriptors.h> | ||||||
| #include <linux/usb/gadget.h> | #include <linux/usb/gadget.h> | ||||||
|  |  | ||||||
| #include <asm/unaligned.h> | #include <asm/unaligned.h> | ||||||
|   | |||||||
| @@ -50,6 +50,7 @@ COBJS-$(CONFIG_USB_EHCI_PPC4XX) += ehci-ppc4xx.o | |||||||
| COBJS-$(CONFIG_USB_EHCI_IXP4XX) += ehci-ixp.o | COBJS-$(CONFIG_USB_EHCI_IXP4XX) += ehci-ixp.o | ||||||
| COBJS-$(CONFIG_USB_EHCI_MARVELL) += ehci-marvell.o | COBJS-$(CONFIG_USB_EHCI_MARVELL) += ehci-marvell.o | ||||||
| COBJS-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o | COBJS-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o | ||||||
|  | COBJS-$(CONFIG_USB_EHCI_S5P) += ehci-s5p.o | ||||||
| COBJS-$(CONFIG_USB_EHCI_TEGRA) += ehci-tegra.o | COBJS-$(CONFIG_USB_EHCI_TEGRA) += ehci-tegra.o | ||||||
| COBJS-$(CONFIG_USB_EHCI_VCT) += ehci-vct.o | COBJS-$(CONFIG_USB_EHCI_VCT) += ehci-vct.o | ||||||
|  |  | ||||||
|   | |||||||
| @@ -108,99 +108,6 @@ static struct descriptor { | |||||||
| #define ehci_is_TDI()	(0) | #define ehci_is_TDI()	(0) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(CONFIG_EHCI_DCACHE) |  | ||||||
| /* |  | ||||||
|  * Routines to handle (flush/invalidate) the dcache for the QH and qTD |  | ||||||
|  * structures and data buffers. This is needed on platforms using this |  | ||||||
|  * EHCI support with dcache enabled. |  | ||||||
|  */ |  | ||||||
| static void flush_invalidate(u32 addr, int size, int flush) |  | ||||||
| { |  | ||||||
| 	if (flush) |  | ||||||
| 		flush_dcache_range(addr, addr + size); |  | ||||||
| 	else |  | ||||||
| 		invalidate_dcache_range(addr, addr + size); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static void cache_qtd(struct qTD *qtd, int flush) |  | ||||||
| { |  | ||||||
| 	u32 *ptr = (u32 *)qtd->qt_buffer[0]; |  | ||||||
| 	int len = (qtd->qt_token & 0x7fff0000) >> 16; |  | ||||||
|  |  | ||||||
| 	flush_invalidate((u32)qtd, sizeof(struct qTD), flush); |  | ||||||
| 	if (ptr && len) |  | ||||||
| 		flush_invalidate((u32)ptr, len, flush); |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  |  | ||||||
| static inline struct QH *qh_addr(struct QH *qh) |  | ||||||
| { |  | ||||||
| 	return (struct QH *)((u32)qh & 0xffffffe0); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static void cache_qh(struct QH *qh, int flush) |  | ||||||
| { |  | ||||||
| 	struct qTD *qtd; |  | ||||||
| 	struct qTD *next; |  | ||||||
| 	static struct qTD *first_qtd; |  | ||||||
|  |  | ||||||
| 	/* |  | ||||||
| 	 * Walk the QH list and flush/invalidate all entries |  | ||||||
| 	 */ |  | ||||||
| 	while (1) { |  | ||||||
| 		flush_invalidate((u32)qh_addr(qh), sizeof(struct QH), flush); |  | ||||||
| 		if ((u32)qh & QH_LINK_TYPE_QH) |  | ||||||
| 			break; |  | ||||||
| 		qh = qh_addr(qh); |  | ||||||
| 		qh = (struct QH *)qh->qh_link; |  | ||||||
| 	} |  | ||||||
| 	qh = qh_addr(qh); |  | ||||||
|  |  | ||||||
| 	/* |  | ||||||
| 	 * Save first qTD pointer, needed for invalidating pass on this QH |  | ||||||
| 	 */ |  | ||||||
| 	if (flush) |  | ||||||
| 		first_qtd = qtd = (struct qTD *)(*(u32 *)&qh->qh_overlay & |  | ||||||
| 						 0xffffffe0); |  | ||||||
| 	else |  | ||||||
| 		qtd = first_qtd; |  | ||||||
|  |  | ||||||
| 	/* |  | ||||||
| 	 * Walk the qTD list and flush/invalidate all entries |  | ||||||
| 	 */ |  | ||||||
| 	while (1) { |  | ||||||
| 		if (qtd == NULL) |  | ||||||
| 			break; |  | ||||||
| 		cache_qtd(qtd, flush); |  | ||||||
| 		next = (struct qTD *)((u32)qtd->qt_next & 0xffffffe0); |  | ||||||
| 		if (next == qtd) |  | ||||||
| 			break; |  | ||||||
| 		qtd = next; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static inline void ehci_flush_dcache(struct QH *qh) |  | ||||||
| { |  | ||||||
| 	cache_qh(qh, 1); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static inline void ehci_invalidate_dcache(struct QH *qh) |  | ||||||
| { |  | ||||||
| 	cache_qh(qh, 0); |  | ||||||
| } |  | ||||||
| #else /* CONFIG_EHCI_DCACHE */ |  | ||||||
| /* |  | ||||||
|  * |  | ||||||
|  */ |  | ||||||
| static inline void ehci_flush_dcache(struct QH *qh) |  | ||||||
| { |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static inline void ehci_invalidate_dcache(struct QH *qh) |  | ||||||
| { |  | ||||||
| } |  | ||||||
| #endif /* CONFIG_EHCI_DCACHE */ |  | ||||||
|  |  | ||||||
| void __ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg) | void __ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg) | ||||||
| { | { | ||||||
| 	mdelay(50); | 	mdelay(50); | ||||||
| @@ -225,11 +132,6 @@ static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec) | |||||||
| 	return -1; | 	return -1; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void ehci_free(void *p, size_t sz) |  | ||||||
| { |  | ||||||
|  |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static int ehci_reset(void) | static int ehci_reset(void) | ||||||
| { | { | ||||||
| 	uint32_t cmd; | 	uint32_t cmd; | ||||||
| @@ -266,43 +168,22 @@ out: | |||||||
| 	return ret; | 	return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void *ehci_alloc(size_t sz, size_t align) |  | ||||||
| { |  | ||||||
| 	static struct QH qh __attribute__((aligned(32))); |  | ||||||
| 	static struct qTD td[3] __attribute__((aligned (32))); |  | ||||||
| 	static int ntds; |  | ||||||
| 	void *p; |  | ||||||
|  |  | ||||||
| 	switch (sz) { |  | ||||||
| 	case sizeof(struct QH): |  | ||||||
| 		p = &qh; |  | ||||||
| 		ntds = 0; |  | ||||||
| 		break; |  | ||||||
| 	case sizeof(struct qTD): |  | ||||||
| 		if (ntds == 3) { |  | ||||||
| 			debug("out of TDs\n"); |  | ||||||
| 			return NULL; |  | ||||||
| 		} |  | ||||||
| 		p = &td[ntds]; |  | ||||||
| 		ntds++; |  | ||||||
| 		break; |  | ||||||
| 	default: |  | ||||||
| 		debug("unknown allocation size\n"); |  | ||||||
| 		return NULL; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	memset(p, 0, sz); |  | ||||||
| 	return p; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz) | static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz) | ||||||
| { | { | ||||||
| 	uint32_t addr, delta, next; | 	uint32_t delta, next; | ||||||
|  | 	uint32_t addr = (uint32_t)buf; | ||||||
|  | 	size_t rsz = roundup(sz, 32); | ||||||
| 	int idx; | 	int idx; | ||||||
|  |  | ||||||
| 	addr = (uint32_t) buf; | 	if (sz != rsz) | ||||||
|  | 		debug("EHCI-HCD: Misaligned buffer size (%08x)\n", sz); | ||||||
|  |  | ||||||
|  | 	if (addr & 31) | ||||||
|  | 		debug("EHCI-HCD: Misaligned buffer address (%p)\n", buf); | ||||||
|  |  | ||||||
| 	idx = 0; | 	idx = 0; | ||||||
| 	while (idx < 5) { | 	while (idx < 5) { | ||||||
|  | 		flush_dcache_range(addr, addr + rsz); | ||||||
| 		td->qt_buffer[idx] = cpu_to_hc32(addr); | 		td->qt_buffer[idx] = cpu_to_hc32(addr); | ||||||
| 		td->qt_buffer_hi[idx] = 0; | 		td->qt_buffer_hi[idx] = 0; | ||||||
| 		next = (addr + 4096) & ~4095; | 		next = (addr + 4096) & ~4095; | ||||||
| @@ -326,8 +207,10 @@ static int | |||||||
| ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, | ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, | ||||||
| 		   int length, struct devrequest *req) | 		   int length, struct devrequest *req) | ||||||
| { | { | ||||||
| 	struct QH *qh; | 	static struct QH qh __attribute__((aligned(32))); | ||||||
| 	struct qTD *td; | 	static struct qTD qtd[3] __attribute__((aligned (32))); | ||||||
|  | 	int qtd_counter = 0; | ||||||
|  |  | ||||||
| 	volatile struct qTD *vtd; | 	volatile struct qTD *vtd; | ||||||
| 	unsigned long ts; | 	unsigned long ts; | ||||||
| 	uint32_t *tdp; | 	uint32_t *tdp; | ||||||
| @@ -346,12 +229,22 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, | |||||||
| 		      le16_to_cpu(req->value), le16_to_cpu(req->value), | 		      le16_to_cpu(req->value), le16_to_cpu(req->value), | ||||||
| 		      le16_to_cpu(req->index)); | 		      le16_to_cpu(req->index)); | ||||||
|  |  | ||||||
| 	qh = ehci_alloc(sizeof(struct QH), 32); | 	memset(&qh, 0, sizeof(struct QH)); | ||||||
| 	if (qh == NULL) { | 	memset(qtd, 0, sizeof(qtd)); | ||||||
| 		debug("unable to allocate QH\n"); |  | ||||||
| 		return -1; | 	toggle = usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe)); | ||||||
| 	} |  | ||||||
| 	qh->qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH); | 	/* | ||||||
|  | 	 * Setup QH (3.6 in ehci-r10.pdf) | ||||||
|  | 	 * | ||||||
|  | 	 *   qh_link ................. 03-00 H | ||||||
|  | 	 *   qh_endpt1 ............... 07-04 H | ||||||
|  | 	 *   qh_endpt2 ............... 0B-08 H | ||||||
|  | 	 * - qh_curtd | ||||||
|  | 	 *   qh_overlay.qt_next ...... 13-10 H | ||||||
|  | 	 * - qh_overlay.qt_altnext | ||||||
|  | 	 */ | ||||||
|  | 	qh.qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH); | ||||||
| 	c = (usb_pipespeed(pipe) != USB_SPEED_HIGH && | 	c = (usb_pipespeed(pipe) != USB_SPEED_HIGH && | ||||||
| 	     usb_pipeendpoint(pipe) == 0) ? 1 : 0; | 	     usb_pipeendpoint(pipe) == 0) ? 1 : 0; | ||||||
| 	endpt = (8 << 28) | | 	endpt = (8 << 28) | | ||||||
| @@ -362,88 +255,98 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, | |||||||
| 	    (usb_pipespeed(pipe) << 12) | | 	    (usb_pipespeed(pipe) << 12) | | ||||||
| 	    (usb_pipeendpoint(pipe) << 8) | | 	    (usb_pipeendpoint(pipe) << 8) | | ||||||
| 	    (0 << 7) | (usb_pipedevice(pipe) << 0); | 	    (0 << 7) | (usb_pipedevice(pipe) << 0); | ||||||
| 	qh->qh_endpt1 = cpu_to_hc32(endpt); | 	qh.qh_endpt1 = cpu_to_hc32(endpt); | ||||||
| 	endpt = (1 << 30) | | 	endpt = (1 << 30) | | ||||||
| 	    (dev->portnr << 23) | | 	    (dev->portnr << 23) | | ||||||
| 	    (dev->parent->devnum << 16) | (0 << 8) | (0 << 0); | 	    (dev->parent->devnum << 16) | (0 << 8) | (0 << 0); | ||||||
| 	qh->qh_endpt2 = cpu_to_hc32(endpt); | 	qh.qh_endpt2 = cpu_to_hc32(endpt); | ||||||
| 	qh->qh_overlay.qt_next = cpu_to_hc32(QT_NEXT_TERMINATE); | 	qh.qh_overlay.qt_next = cpu_to_hc32(QT_NEXT_TERMINATE); | ||||||
|  |  | ||||||
| 	td = NULL; | 	tdp = &qh.qh_overlay.qt_next; | ||||||
| 	tdp = &qh->qh_overlay.qt_next; |  | ||||||
|  |  | ||||||
| 	toggle = |  | ||||||
| 	    usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe)); |  | ||||||
|  |  | ||||||
| 	if (req != NULL) { | 	if (req != NULL) { | ||||||
| 		td = ehci_alloc(sizeof(struct qTD), 32); | 		/* | ||||||
| 		if (td == NULL) { | 		 * Setup request qTD (3.5 in ehci-r10.pdf) | ||||||
| 			debug("unable to allocate SETUP td\n"); | 		 * | ||||||
| 			goto fail; | 		 *   qt_next ................ 03-00 H | ||||||
| 		} | 		 *   qt_altnext ............. 07-04 H | ||||||
| 		td->qt_next = cpu_to_hc32(QT_NEXT_TERMINATE); | 		 *   qt_token ............... 0B-08 H | ||||||
| 		td->qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE); | 		 * | ||||||
|  | 		 *   [ buffer, buffer_hi ] loaded with "req". | ||||||
|  | 		 */ | ||||||
|  | 		qtd[qtd_counter].qt_next = cpu_to_hc32(QT_NEXT_TERMINATE); | ||||||
|  | 		qtd[qtd_counter].qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE); | ||||||
| 		token = (0 << 31) | | 		token = (0 << 31) | | ||||||
| 		    (sizeof(*req) << 16) | | 		    (sizeof(*req) << 16) | | ||||||
| 		    (0 << 15) | (0 << 12) | (3 << 10) | (2 << 8) | (0x80 << 0); | 		    (0 << 15) | (0 << 12) | (3 << 10) | (2 << 8) | (0x80 << 0); | ||||||
| 		td->qt_token = cpu_to_hc32(token); | 		qtd[qtd_counter].qt_token = cpu_to_hc32(token); | ||||||
| 		if (ehci_td_buffer(td, req, sizeof(*req)) != 0) { | 		if (ehci_td_buffer(&qtd[qtd_counter], req, sizeof(*req)) != 0) { | ||||||
| 			debug("unable construct SETUP td\n"); | 			debug("unable construct SETUP td\n"); | ||||||
| 			ehci_free(td, sizeof(*td)); |  | ||||||
| 			goto fail; | 			goto fail; | ||||||
| 		} | 		} | ||||||
| 		*tdp = cpu_to_hc32((uint32_t) td); | 		/* Update previous qTD! */ | ||||||
| 		tdp = &td->qt_next; | 		*tdp = cpu_to_hc32((uint32_t)&qtd[qtd_counter]); | ||||||
|  | 		tdp = &qtd[qtd_counter++].qt_next; | ||||||
| 		toggle = 1; | 		toggle = 1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (length > 0 || req == NULL) { | 	if (length > 0 || req == NULL) { | ||||||
| 		td = ehci_alloc(sizeof(struct qTD), 32); | 		/* | ||||||
| 		if (td == NULL) { | 		 * Setup request qTD (3.5 in ehci-r10.pdf) | ||||||
| 			debug("unable to allocate DATA td\n"); | 		 * | ||||||
| 			goto fail; | 		 *   qt_next ................ 03-00 H | ||||||
| 		} | 		 *   qt_altnext ............. 07-04 H | ||||||
| 		td->qt_next = cpu_to_hc32(QT_NEXT_TERMINATE); | 		 *   qt_token ............... 0B-08 H | ||||||
| 		td->qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE); | 		 * | ||||||
|  | 		 *   [ buffer, buffer_hi ] loaded with "buffer". | ||||||
|  | 		 */ | ||||||
|  | 		qtd[qtd_counter].qt_next = cpu_to_hc32(QT_NEXT_TERMINATE); | ||||||
|  | 		qtd[qtd_counter].qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE); | ||||||
| 		token = (toggle << 31) | | 		token = (toggle << 31) | | ||||||
| 		    (length << 16) | | 		    (length << 16) | | ||||||
| 		    ((req == NULL ? 1 : 0) << 15) | | 		    ((req == NULL ? 1 : 0) << 15) | | ||||||
| 		    (0 << 12) | | 		    (0 << 12) | | ||||||
| 		    (3 << 10) | | 		    (3 << 10) | | ||||||
| 		    ((usb_pipein(pipe) ? 1 : 0) << 8) | (0x80 << 0); | 		    ((usb_pipein(pipe) ? 1 : 0) << 8) | (0x80 << 0); | ||||||
| 		td->qt_token = cpu_to_hc32(token); | 		qtd[qtd_counter].qt_token = cpu_to_hc32(token); | ||||||
| 		if (ehci_td_buffer(td, buffer, length) != 0) { | 		if (ehci_td_buffer(&qtd[qtd_counter], buffer, length) != 0) { | ||||||
| 			debug("unable construct DATA td\n"); | 			debug("unable construct DATA td\n"); | ||||||
| 			ehci_free(td, sizeof(*td)); |  | ||||||
| 			goto fail; | 			goto fail; | ||||||
| 		} | 		} | ||||||
| 		*tdp = cpu_to_hc32((uint32_t) td); | 		/* Update previous qTD! */ | ||||||
| 		tdp = &td->qt_next; | 		*tdp = cpu_to_hc32((uint32_t)&qtd[qtd_counter]); | ||||||
|  | 		tdp = &qtd[qtd_counter++].qt_next; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (req != NULL) { | 	if (req != NULL) { | ||||||
| 		td = ehci_alloc(sizeof(struct qTD), 32); | 		/* | ||||||
| 		if (td == NULL) { | 		 * Setup request qTD (3.5 in ehci-r10.pdf) | ||||||
| 			debug("unable to allocate ACK td\n"); | 		 * | ||||||
| 			goto fail; | 		 *   qt_next ................ 03-00 H | ||||||
| 		} | 		 *   qt_altnext ............. 07-04 H | ||||||
| 		td->qt_next = cpu_to_hc32(QT_NEXT_TERMINATE); | 		 *   qt_token ............... 0B-08 H | ||||||
| 		td->qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE); | 		 */ | ||||||
|  | 		qtd[qtd_counter].qt_next = cpu_to_hc32(QT_NEXT_TERMINATE); | ||||||
|  | 		qtd[qtd_counter].qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE); | ||||||
| 		token = (toggle << 31) | | 		token = (toggle << 31) | | ||||||
| 		    (0 << 16) | | 		    (0 << 16) | | ||||||
| 		    (1 << 15) | | 		    (1 << 15) | | ||||||
| 		    (0 << 12) | | 		    (0 << 12) | | ||||||
| 		    (3 << 10) | | 		    (3 << 10) | | ||||||
| 		    ((usb_pipein(pipe) ? 0 : 1) << 8) | (0x80 << 0); | 		    ((usb_pipein(pipe) ? 0 : 1) << 8) | (0x80 << 0); | ||||||
| 		td->qt_token = cpu_to_hc32(token); | 		qtd[qtd_counter].qt_token = cpu_to_hc32(token); | ||||||
| 		*tdp = cpu_to_hc32((uint32_t) td); | 		/* Update previous qTD! */ | ||||||
| 		tdp = &td->qt_next; | 		*tdp = cpu_to_hc32((uint32_t)&qtd[qtd_counter]); | ||||||
|  | 		tdp = &qtd[qtd_counter++].qt_next; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	qh_list.qh_link = cpu_to_hc32((uint32_t) qh | QH_LINK_TYPE_QH); | 	qh_list.qh_link = cpu_to_hc32((uint32_t)&qh | QH_LINK_TYPE_QH); | ||||||
|  |  | ||||||
| 	/* Flush dcache */ | 	/* Flush dcache */ | ||||||
| 	ehci_flush_dcache(&qh_list); | 	flush_dcache_range((uint32_t)&qh_list, | ||||||
|  | 		(uint32_t)&qh_list + sizeof(struct QH)); | ||||||
|  | 	flush_dcache_range((uint32_t)&qh, (uint32_t)&qh + sizeof(struct QH)); | ||||||
|  | 	flush_dcache_range((uint32_t)qtd, (uint32_t)qtd + sizeof(qtd)); | ||||||
|  |  | ||||||
| 	usbsts = ehci_readl(&hcor->or_usbsts); | 	usbsts = ehci_readl(&hcor->or_usbsts); | ||||||
| 	ehci_writel(&hcor->or_usbsts, (usbsts & 0x3f)); | 	ehci_writel(&hcor->or_usbsts, (usbsts & 0x3f)); | ||||||
| @@ -462,17 +365,27 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, | |||||||
|  |  | ||||||
| 	/* Wait for TDs to be processed. */ | 	/* Wait for TDs to be processed. */ | ||||||
| 	ts = get_timer(0); | 	ts = get_timer(0); | ||||||
| 	vtd = td; | 	vtd = &qtd[qtd_counter - 1]; | ||||||
| 	timeout = USB_TIMEOUT_MS(pipe); | 	timeout = USB_TIMEOUT_MS(pipe); | ||||||
| 	do { | 	do { | ||||||
| 		/* Invalidate dcache */ | 		/* Invalidate dcache */ | ||||||
| 		ehci_invalidate_dcache(&qh_list); | 		invalidate_dcache_range((uint32_t)&qh_list, | ||||||
|  | 			(uint32_t)&qh_list + sizeof(struct QH)); | ||||||
|  | 		invalidate_dcache_range((uint32_t)&qh, | ||||||
|  | 			(uint32_t)&qh + sizeof(struct QH)); | ||||||
|  | 		invalidate_dcache_range((uint32_t)qtd, | ||||||
|  | 			(uint32_t)qtd + sizeof(qtd)); | ||||||
|  |  | ||||||
| 		token = hc32_to_cpu(vtd->qt_token); | 		token = hc32_to_cpu(vtd->qt_token); | ||||||
| 		if (!(token & 0x80)) | 		if (!(token & 0x80)) | ||||||
| 			break; | 			break; | ||||||
| 		WATCHDOG_RESET(); | 		WATCHDOG_RESET(); | ||||||
| 	} while (get_timer(ts) < timeout); | 	} while (get_timer(ts) < timeout); | ||||||
|  |  | ||||||
|  | 	/* Invalidate the memory area occupied by buffer */ | ||||||
|  | 	invalidate_dcache_range(((uint32_t)buffer & ~31), | ||||||
|  | 		((uint32_t)buffer & ~31) + roundup(length, 32)); | ||||||
|  |  | ||||||
| 	/* Check that the TD processing happened */ | 	/* Check that the TD processing happened */ | ||||||
| 	if (token & 0x80) { | 	if (token & 0x80) { | ||||||
| 		printf("EHCI timed out on TD - token=%#x\n", token); | 		printf("EHCI timed out on TD - token=%#x\n", token); | ||||||
| @@ -492,7 +405,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, | |||||||
|  |  | ||||||
| 	qh_list.qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH); | 	qh_list.qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH); | ||||||
|  |  | ||||||
| 	token = hc32_to_cpu(qh->qh_overlay.qt_token); | 	token = hc32_to_cpu(qh.qh_overlay.qt_token); | ||||||
| 	if (!(token & 0x80)) { | 	if (!(token & 0x80)) { | ||||||
| 		debug("TOKEN=%#x\n", token); | 		debug("TOKEN=%#x\n", token); | ||||||
| 		switch (token & 0xfc) { | 		switch (token & 0xfc) { | ||||||
| @@ -531,13 +444,6 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, | |||||||
| 	return (dev->status != USB_ST_NOT_PROC) ? 0 : -1; | 	return (dev->status != USB_ST_NOT_PROC) ? 0 : -1; | ||||||
|  |  | ||||||
| fail: | fail: | ||||||
| 	td = (void *)hc32_to_cpu(qh->qh_overlay.qt_next); |  | ||||||
| 	while (td != (void *)QT_NEXT_TERMINATE) { |  | ||||||
| 		qh->qh_overlay.qt_next = td->qt_next; |  | ||||||
| 		ehci_free(td, sizeof(*td)); |  | ||||||
| 		td = (void *)hc32_to_cpu(qh->qh_overlay.qt_next); |  | ||||||
| 	} |  | ||||||
| 	ehci_free(qh, sizeof(*qh)); |  | ||||||
| 	return -1; | 	return -1; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										110
									
								
								drivers/usb/host/ehci-s5p.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								drivers/usb/host/ehci-s5p.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,110 @@ | |||||||
|  | /* | ||||||
|  |  * SAMSUNG S5P USB HOST EHCI Controller | ||||||
|  |  * | ||||||
|  |  * Copyright (C) 2012 Samsung Electronics Co.Ltd | ||||||
|  |  *	Vivek Gautam <gautam.vivek@samsung.com> | ||||||
|  |  * | ||||||
|  |  * This program is free software; you can redistribute it and/or | ||||||
|  |  * modify it under the terms of the GNU General Public License as | ||||||
|  |  * published by the Free Software Foundation; either version 2 of | ||||||
|  |  * the License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with this program; if not, write to the Free Software | ||||||
|  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||||||
|  |  * MA 02110-1301 USA | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #include <common.h> | ||||||
|  | #include <usb.h> | ||||||
|  | #include <asm/arch/cpu.h> | ||||||
|  | #include <asm/arch/ehci-s5p.h> | ||||||
|  | #include "ehci.h" | ||||||
|  | #include "ehci-core.h" | ||||||
|  |  | ||||||
|  | /* Setup the EHCI host controller. */ | ||||||
|  | static void setup_usb_phy(struct s5p_usb_phy *usb) | ||||||
|  | { | ||||||
|  | 	clrbits_le32(&usb->usbphyctrl0, | ||||||
|  | 			HOST_CTRL0_FSEL_MASK | | ||||||
|  | 			HOST_CTRL0_COMMONON_N | | ||||||
|  | 			/* HOST Phy setting */ | ||||||
|  | 			HOST_CTRL0_PHYSWRST | | ||||||
|  | 			HOST_CTRL0_PHYSWRSTALL | | ||||||
|  | 			HOST_CTRL0_SIDDQ | | ||||||
|  | 			HOST_CTRL0_FORCESUSPEND | | ||||||
|  | 			HOST_CTRL0_FORCESLEEP); | ||||||
|  |  | ||||||
|  | 	setbits_le32(&usb->usbphyctrl0, | ||||||
|  | 			/* Setting up the ref freq */ | ||||||
|  | 			(CLK_24MHZ << 16) | | ||||||
|  | 			/* HOST Phy setting */ | ||||||
|  | 			HOST_CTRL0_LINKSWRST | | ||||||
|  | 			HOST_CTRL0_UTMISWRST); | ||||||
|  | 	udelay(10); | ||||||
|  | 	clrbits_le32(&usb->usbphyctrl0, | ||||||
|  | 			HOST_CTRL0_LINKSWRST | | ||||||
|  | 			HOST_CTRL0_UTMISWRST); | ||||||
|  | 	udelay(20); | ||||||
|  |  | ||||||
|  | 	/* EHCI Ctrl setting */ | ||||||
|  | 	setbits_le32(&usb->ehcictrl, | ||||||
|  | 			EHCICTRL_ENAINCRXALIGN | | ||||||
|  | 			EHCICTRL_ENAINCR4 | | ||||||
|  | 			EHCICTRL_ENAINCR8 | | ||||||
|  | 			EHCICTRL_ENAINCR16); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /* Reset the EHCI host controller. */ | ||||||
|  | static void reset_usb_phy(struct s5p_usb_phy *usb) | ||||||
|  | { | ||||||
|  | 	/* HOST_PHY reset */ | ||||||
|  | 	setbits_le32(&usb->usbphyctrl0, | ||||||
|  | 			HOST_CTRL0_PHYSWRST | | ||||||
|  | 			HOST_CTRL0_PHYSWRSTALL | | ||||||
|  | 			HOST_CTRL0_SIDDQ | | ||||||
|  | 			HOST_CTRL0_FORCESUSPEND | | ||||||
|  | 			HOST_CTRL0_FORCESLEEP); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * EHCI-initialization | ||||||
|  |  * Create the appropriate control structures to manage | ||||||
|  |  * a new EHCI host controller. | ||||||
|  |  */ | ||||||
|  | int ehci_hcd_init(void) | ||||||
|  | { | ||||||
|  | 	struct s5p_usb_phy *usb; | ||||||
|  |  | ||||||
|  | 	usb = (struct s5p_usb_phy *)samsung_get_base_usb_phy(); | ||||||
|  | 	setup_usb_phy(usb); | ||||||
|  |  | ||||||
|  | 	hccr = (struct ehci_hccr *)(EXYNOS5_USB_HOST_EHCI_BASE); | ||||||
|  | 	hcor = (struct ehci_hcor *)((uint32_t) hccr | ||||||
|  | 				+ HC_LENGTH(ehci_readl(&hccr->cr_capbase))); | ||||||
|  |  | ||||||
|  | 	debug("Exynos5-ehci: init hccr %x and hcor %x hc_length %d\n", | ||||||
|  | 		(uint32_t)hccr, (uint32_t)hcor, | ||||||
|  | 		(uint32_t)HC_LENGTH(ehci_readl(&hccr->cr_capbase))); | ||||||
|  |  | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * Destroy the appropriate control structures corresponding | ||||||
|  |  * the EHCI host controller. | ||||||
|  |  */ | ||||||
|  | int ehci_hcd_stop() | ||||||
|  | { | ||||||
|  | 	struct s5p_usb_phy *usb; | ||||||
|  |  | ||||||
|  | 	usb = (struct s5p_usb_phy *)samsung_get_base_usb_phy(); | ||||||
|  | 	reset_usb_phy(usb); | ||||||
|  |  | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
| @@ -204,28 +204,6 @@ struct usb_descriptor_header { | |||||||
| 	__u8  bDescriptorType; | 	__u8  bDescriptorType; | ||||||
| } __attribute__ ((packed)); | } __attribute__ ((packed)); | ||||||
|  |  | ||||||
|  |  | ||||||
| /*-------------------------------------------------------------------------*/ |  | ||||||
|  |  | ||||||
| /* USB_DT_DEVICE: Device descriptor */ |  | ||||||
| struct usb_device_descriptor { |  | ||||||
| 	__u8  bLength; |  | ||||||
| 	__u8  bDescriptorType; |  | ||||||
|  |  | ||||||
| 	__le16 bcdUSB; |  | ||||||
| 	__u8  bDeviceClass; |  | ||||||
| 	__u8  bDeviceSubClass; |  | ||||||
| 	__u8  bDeviceProtocol; |  | ||||||
| 	__u8  bMaxPacketSize0; |  | ||||||
| 	__le16 idVendor; |  | ||||||
| 	__le16 idProduct; |  | ||||||
| 	__le16 bcdDevice; |  | ||||||
| 	__u8  iManufacturer; |  | ||||||
| 	__u8  iProduct; |  | ||||||
| 	__u8  iSerialNumber; |  | ||||||
| 	__u8  bNumConfigurations; |  | ||||||
| } __attribute__ ((packed)); |  | ||||||
|  |  | ||||||
| #define USB_DT_DEVICE_SIZE		18 | #define USB_DT_DEVICE_SIZE		18 | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -282,56 +260,11 @@ struct usb_config_descriptor { | |||||||
| #define USB_CONFIG_ATT_WAKEUP		(1 << 5)	/* can wakeup */ | #define USB_CONFIG_ATT_WAKEUP		(1 << 5)	/* can wakeup */ | ||||||
| #define USB_CONFIG_ATT_BATTERY		(1 << 4)	/* battery powered */ | #define USB_CONFIG_ATT_BATTERY		(1 << 4)	/* battery powered */ | ||||||
|  |  | ||||||
| /*-------------------------------------------------------------------------*/ |  | ||||||
|  |  | ||||||
| /* USB_DT_STRING: String descriptor */ |  | ||||||
| struct usb_string_descriptor { |  | ||||||
| 	__u8  bLength; |  | ||||||
| 	__u8  bDescriptorType; |  | ||||||
|  |  | ||||||
| 	__le16 wData[1];		/* UTF-16LE encoded */ |  | ||||||
| } __attribute__ ((packed)); |  | ||||||
|  |  | ||||||
| /* note that "string" zero is special, it holds language codes that | /* note that "string" zero is special, it holds language codes that | ||||||
|  * the device supports, not Unicode characters. |  * the device supports, not Unicode characters. | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| /*-------------------------------------------------------------------------*/ |  | ||||||
|  |  | ||||||
| /* USB_DT_INTERFACE: Interface descriptor */ |  | ||||||
| struct usb_interface_descriptor { |  | ||||||
| 	__u8  bLength; |  | ||||||
| 	__u8  bDescriptorType; |  | ||||||
|  |  | ||||||
| 	__u8  bInterfaceNumber; |  | ||||||
| 	__u8  bAlternateSetting; |  | ||||||
| 	__u8  bNumEndpoints; |  | ||||||
| 	__u8  bInterfaceClass; |  | ||||||
| 	__u8  bInterfaceSubClass; |  | ||||||
| 	__u8  bInterfaceProtocol; |  | ||||||
| 	__u8  iInterface; |  | ||||||
| } __attribute__ ((packed)); |  | ||||||
|  |  | ||||||
| #define USB_DT_INTERFACE_SIZE		9 | #define USB_DT_INTERFACE_SIZE		9 | ||||||
|  |  | ||||||
| /*-------------------------------------------------------------------------*/ |  | ||||||
|  |  | ||||||
| /* USB_DT_ENDPOINT: Endpoint descriptor */ |  | ||||||
| struct usb_endpoint_descriptor { |  | ||||||
| 	__u8  bLength; |  | ||||||
| 	__u8  bDescriptorType; |  | ||||||
|  |  | ||||||
| 	__u8  bEndpointAddress; |  | ||||||
| 	__u8  bmAttributes; |  | ||||||
| 	__le16 wMaxPacketSize; |  | ||||||
| 	__u8  bInterval; |  | ||||||
|  |  | ||||||
| 	/* NOTE:  these two are _only_ in audio endpoints. */ |  | ||||||
| 	/* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ |  | ||||||
| 	__u8  bRefresh; |  | ||||||
| 	__u8  bSynchAddress; |  | ||||||
| } __attribute__ ((packed)); |  | ||||||
|  |  | ||||||
| #define USB_DT_ENDPOINT_SIZE		7 | #define USB_DT_ENDPOINT_SIZE		7 | ||||||
| #define USB_DT_ENDPOINT_AUDIO_SIZE	9	/* Audio extension */ | #define USB_DT_ENDPOINT_AUDIO_SIZE	9	/* Audio extension */ | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										350
									
								
								include/linux/usb/composite.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										350
									
								
								include/linux/usb/composite.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,350 @@ | |||||||
|  | /* | ||||||
|  |  * composite.h -- framework for usb gadgets which are composite devices | ||||||
|  |  * | ||||||
|  |  * Copyright (C) 2006-2008 David Brownell | ||||||
|  |  * | ||||||
|  |  * This program is free software; you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation; either version 2 of the License, or | ||||||
|  |  * (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with this program; if not, write to the Free Software | ||||||
|  |  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #ifndef	__LINUX_USB_COMPOSITE_H | ||||||
|  | #define	__LINUX_USB_COMPOSITE_H | ||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * This framework is an optional layer on top of the USB Gadget interface, | ||||||
|  |  * making it easier to build (a) Composite devices, supporting multiple | ||||||
|  |  * functions within any single configuration, and (b) Multi-configuration | ||||||
|  |  * devices, also supporting multiple functions but without necessarily | ||||||
|  |  * having more than one function per configuration. | ||||||
|  |  * | ||||||
|  |  * Example:  a device with a single configuration supporting both network | ||||||
|  |  * link and mass storage functions is a composite device.  Those functions | ||||||
|  |  * might alternatively be packaged in individual configurations, but in | ||||||
|  |  * the composite model the host can use both functions at the same time. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #include <common.h> | ||||||
|  | #include <linux/usb/ch9.h> | ||||||
|  | #include <linux/usb/gadget.h> | ||||||
|  | #include <usb/lin_gadget_compat.h> | ||||||
|  |  | ||||||
|  | struct usb_configuration; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * struct usb_function - describes one function of a configuration | ||||||
|  |  * @name: For diagnostics, identifies the function. | ||||||
|  |  * @strings: tables of strings, keyed by identifiers assigned during bind() | ||||||
|  |  *	and by language IDs provided in control requests | ||||||
|  |  * @descriptors: Table of full (or low) speed descriptors, using interface and | ||||||
|  |  *	string identifiers assigned during @bind().  If this pointer is null, | ||||||
|  |  *	the function will not be available at full speed (or at low speed). | ||||||
|  |  * @hs_descriptors: Table of high speed descriptors, using interface and | ||||||
|  |  *	string identifiers assigned during @bind().  If this pointer is null, | ||||||
|  |  *	the function will not be available at high speed. | ||||||
|  |  * @config: assigned when @usb_add_function() is called; this is the | ||||||
|  |  *	configuration with which this function is associated. | ||||||
|  |  * @bind: Before the gadget can register, all of its functions bind() to the | ||||||
|  |  *	available resources including string and interface identifiers used | ||||||
|  |  *	in interface or class descriptors; endpoints; I/O buffers; and so on. | ||||||
|  |  * @unbind: Reverses @bind; called as a side effect of unregistering the | ||||||
|  |  *	driver which added this function. | ||||||
|  |  * @set_alt: (REQUIRED) Reconfigures altsettings; function drivers may | ||||||
|  |  *	initialize usb_ep.driver data at this time (when it is used). | ||||||
|  |  *	Note that setting an interface to its current altsetting resets | ||||||
|  |  *	interface state, and that all interfaces have a disabled state. | ||||||
|  |  * @get_alt: Returns the active altsetting.  If this is not provided, | ||||||
|  |  *	then only altsetting zero is supported. | ||||||
|  |  * @disable: (REQUIRED) Indicates the function should be disabled.  Reasons | ||||||
|  |  *	include host resetting or reconfiguring the gadget, and disconnection. | ||||||
|  |  * @setup: Used for interface-specific control requests. | ||||||
|  |  * @suspend: Notifies functions when the host stops sending USB traffic. | ||||||
|  |  * @resume: Notifies functions when the host restarts USB traffic. | ||||||
|  |  * | ||||||
|  |  * A single USB function uses one or more interfaces, and should in most | ||||||
|  |  * cases support operation at both full and high speeds.  Each function is | ||||||
|  |  * associated by @usb_add_function() with a one configuration; that function | ||||||
|  |  * causes @bind() to be called so resources can be allocated as part of | ||||||
|  |  * setting up a gadget driver.  Those resources include endpoints, which | ||||||
|  |  * should be allocated using @usb_ep_autoconfig(). | ||||||
|  |  * | ||||||
|  |  * To support dual speed operation, a function driver provides descriptors | ||||||
|  |  * for both high and full speed operation.  Except in rare cases that don't | ||||||
|  |  * involve bulk endpoints, each speed needs different endpoint descriptors. | ||||||
|  |  * | ||||||
|  |  * Function drivers choose their own strategies for managing instance data. | ||||||
|  |  * The simplest strategy just declares it "static', which means the function | ||||||
|  |  * can only be activated once.  If the function needs to be exposed in more | ||||||
|  |  * than one configuration at a given speed, it needs to support multiple | ||||||
|  |  * usb_function structures (one for each configuration). | ||||||
|  |  * | ||||||
|  |  * A more complex strategy might encapsulate a @usb_function structure inside | ||||||
|  |  * a driver-specific instance structure to allows multiple activations.  An | ||||||
|  |  * example of multiple activations might be a CDC ACM function that supports | ||||||
|  |  * two or more distinct instances within the same configuration, providing | ||||||
|  |  * several independent logical data links to a USB host. | ||||||
|  |  */ | ||||||
|  | struct usb_function { | ||||||
|  | 	const char			*name; | ||||||
|  | 	struct usb_gadget_strings	**strings; | ||||||
|  | 	struct usb_descriptor_header	**descriptors; | ||||||
|  | 	struct usb_descriptor_header	**hs_descriptors; | ||||||
|  |  | ||||||
|  | 	struct usb_configuration	*config; | ||||||
|  |  | ||||||
|  | 	/* REVISIT:  bind() functions can be marked __init, which | ||||||
|  | 	 * makes trouble for section mismatch analysis.  See if | ||||||
|  | 	 * we can't restructure things to avoid mismatching. | ||||||
|  | 	 * Related:  unbind() may kfree() but bind() won't... | ||||||
|  | 	 */ | ||||||
|  |  | ||||||
|  | 	/* configuration management:  bind/unbind */ | ||||||
|  | 	int			(*bind)(struct usb_configuration *, | ||||||
|  | 					struct usb_function *); | ||||||
|  | 	void			(*unbind)(struct usb_configuration *, | ||||||
|  | 					struct usb_function *); | ||||||
|  |  | ||||||
|  | 	/* runtime state management */ | ||||||
|  | 	int			(*set_alt)(struct usb_function *, | ||||||
|  | 					unsigned interface, unsigned alt); | ||||||
|  | 	int			(*get_alt)(struct usb_function *, | ||||||
|  | 					unsigned interface); | ||||||
|  | 	void			(*disable)(struct usb_function *); | ||||||
|  | 	int			(*setup)(struct usb_function *, | ||||||
|  | 					const struct usb_ctrlrequest *); | ||||||
|  | 	void			(*suspend)(struct usb_function *); | ||||||
|  | 	void			(*resume)(struct usb_function *); | ||||||
|  |  | ||||||
|  | 	/* private: */ | ||||||
|  | 	/* internals */ | ||||||
|  | 	struct list_head		list; | ||||||
|  | 	DECLARE_BITMAP(endpoints, 32); | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | int usb_add_function(struct usb_configuration *, struct usb_function *); | ||||||
|  |  | ||||||
|  | int usb_function_deactivate(struct usb_function *); | ||||||
|  | int usb_function_activate(struct usb_function *); | ||||||
|  |  | ||||||
|  | int usb_interface_id(struct usb_configuration *, struct usb_function *); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * ep_choose - select descriptor endpoint at current device speed | ||||||
|  |  * @g: gadget, connected and running at some speed | ||||||
|  |  * @hs: descriptor to use for high speed operation | ||||||
|  |  * @fs: descriptor to use for full or low speed operation | ||||||
|  |  */ | ||||||
|  | static inline struct usb_endpoint_descriptor * | ||||||
|  | ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs, | ||||||
|  | 		struct usb_endpoint_descriptor *fs) | ||||||
|  | { | ||||||
|  | 	if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) | ||||||
|  | 		return hs; | ||||||
|  | 	return fs; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #define	MAX_CONFIG_INTERFACES		16	/* arbitrary; max 255 */ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * struct usb_configuration - represents one gadget configuration | ||||||
|  |  * @label: For diagnostics, describes the configuration. | ||||||
|  |  * @strings: Tables of strings, keyed by identifiers assigned during @bind() | ||||||
|  |  *	and by language IDs provided in control requests. | ||||||
|  |  * @descriptors: Table of descriptors preceding all function descriptors. | ||||||
|  |  *	Examples include OTG and vendor-specific descriptors. | ||||||
|  |  * @bind: Called from @usb_add_config() to allocate resources unique to this | ||||||
|  |  *	configuration and to call @usb_add_function() for each function used. | ||||||
|  |  * @unbind: Reverses @bind; called as a side effect of unregistering the | ||||||
|  |  *	driver which added this configuration. | ||||||
|  |  * @setup: Used to delegate control requests that aren't handled by standard | ||||||
|  |  *	device infrastructure or directed at a specific interface. | ||||||
|  |  * @bConfigurationValue: Copied into configuration descriptor. | ||||||
|  |  * @iConfiguration: Copied into configuration descriptor. | ||||||
|  |  * @bmAttributes: Copied into configuration descriptor. | ||||||
|  |  * @bMaxPower: Copied into configuration descriptor. | ||||||
|  |  * @cdev: assigned by @usb_add_config() before calling @bind(); this is | ||||||
|  |  *	the device associated with this configuration. | ||||||
|  |  * | ||||||
|  |  * Configurations are building blocks for gadget drivers structured around | ||||||
|  |  * function drivers.  Simple USB gadgets require only one function and one | ||||||
|  |  * configuration, and handle dual-speed hardware by always providing the same | ||||||
|  |  * functionality.  Slightly more complex gadgets may have more than one | ||||||
|  |  * single-function configuration at a given speed; or have configurations | ||||||
|  |  * that only work at one speed. | ||||||
|  |  * | ||||||
|  |  * Composite devices are, by definition, ones with configurations which | ||||||
|  |  * include more than one function. | ||||||
|  |  * | ||||||
|  |  * The lifecycle of a usb_configuration includes allocation, initialization | ||||||
|  |  * of the fields described above, and calling @usb_add_config() to set up | ||||||
|  |  * internal data and bind it to a specific device.  The configuration's | ||||||
|  |  * @bind() method is then used to initialize all the functions and then | ||||||
|  |  * call @usb_add_function() for them. | ||||||
|  |  * | ||||||
|  |  * Those functions would normally be independant of each other, but that's | ||||||
|  |  * not mandatory.  CDC WMC devices are an example where functions often | ||||||
|  |  * depend on other functions, with some functions subsidiary to others. | ||||||
|  |  * Such interdependency may be managed in any way, so long as all of the | ||||||
|  |  * descriptors complete by the time the composite driver returns from | ||||||
|  |  * its bind() routine. | ||||||
|  |  */ | ||||||
|  | struct usb_configuration { | ||||||
|  | 	const char			*label; | ||||||
|  | 	struct usb_gadget_strings	**strings; | ||||||
|  | 	const struct usb_descriptor_header **descriptors; | ||||||
|  |  | ||||||
|  | 	/* REVISIT:  bind() functions can be marked __init, which | ||||||
|  | 	 * makes trouble for section mismatch analysis.  See if | ||||||
|  | 	 * we can't restructure things to avoid mismatching... | ||||||
|  | 	 */ | ||||||
|  |  | ||||||
|  | 	/* configuration management:  bind/unbind */ | ||||||
|  | 	int			(*bind)(struct usb_configuration *); | ||||||
|  | 	void			(*unbind)(struct usb_configuration *); | ||||||
|  | 	int			(*setup)(struct usb_configuration *, | ||||||
|  | 					const struct usb_ctrlrequest *); | ||||||
|  |  | ||||||
|  | 	/* fields in the config descriptor */ | ||||||
|  | 	u8			bConfigurationValue; | ||||||
|  | 	u8			iConfiguration; | ||||||
|  | 	u8			bmAttributes; | ||||||
|  | 	u8			bMaxPower; | ||||||
|  |  | ||||||
|  | 	struct usb_composite_dev	*cdev; | ||||||
|  |  | ||||||
|  | 	/* private: */ | ||||||
|  | 	/* internals */ | ||||||
|  | 	struct list_head	list; | ||||||
|  | 	struct list_head	functions; | ||||||
|  | 	u8			next_interface_id; | ||||||
|  | 	unsigned		highspeed:1; | ||||||
|  | 	unsigned		fullspeed:1; | ||||||
|  | 	struct usb_function	*interface[MAX_CONFIG_INTERFACES]; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | int usb_add_config(struct usb_composite_dev *, | ||||||
|  | 		struct usb_configuration *); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * struct usb_composite_driver - groups configurations into a gadget | ||||||
|  |  * @name: For diagnostics, identifies the driver. | ||||||
|  |  * @dev: Template descriptor for the device, including default device | ||||||
|  |  *	identifiers. | ||||||
|  |  * @strings: tables of strings, keyed by identifiers assigned during bind() | ||||||
|  |  *	and language IDs provided in control requests | ||||||
|  |  * @bind: (REQUIRED) Used to allocate resources that are shared across the | ||||||
|  |  *	whole device, such as string IDs, and add its configurations using | ||||||
|  |  *	@usb_add_config().  This may fail by returning a negative errno | ||||||
|  |  *	value; it should return zero on successful initialization. | ||||||
|  |  * @unbind: Reverses @bind(); called as a side effect of unregistering | ||||||
|  |  *	this driver. | ||||||
|  |  * @disconnect: optional driver disconnect method | ||||||
|  |  * @suspend: Notifies when the host stops sending USB traffic, | ||||||
|  |  *	after function notifications | ||||||
|  |  * @resume: Notifies configuration when the host restarts USB traffic, | ||||||
|  |  *	before function notifications | ||||||
|  |  * | ||||||
|  |  * Devices default to reporting self powered operation.  Devices which rely | ||||||
|  |  * on bus powered operation should report this in their @bind() method. | ||||||
|  |  * | ||||||
|  |  * Before returning from @bind, various fields in the template descriptor | ||||||
|  |  * may be overridden.  These include the idVendor/idProduct/bcdDevice values | ||||||
|  |  * normally to bind the appropriate host side driver, and the three strings | ||||||
|  |  * (iManufacturer, iProduct, iSerialNumber) normally used to provide user | ||||||
|  |  * meaningful device identifiers.  (The strings will not be defined unless | ||||||
|  |  * they are defined in @dev and @strings.)  The correct ep0 maxpacket size | ||||||
|  |  * is also reported, as defined by the underlying controller driver. | ||||||
|  |  */ | ||||||
|  | struct usb_composite_driver { | ||||||
|  | 	const char				*name; | ||||||
|  | 	const struct usb_device_descriptor	*dev; | ||||||
|  | 	struct usb_gadget_strings		**strings; | ||||||
|  |  | ||||||
|  | 	/* REVISIT:  bind() functions can be marked __init, which | ||||||
|  | 	 * makes trouble for section mismatch analysis.  See if | ||||||
|  | 	 * we can't restructure things to avoid mismatching... | ||||||
|  | 	 */ | ||||||
|  |  | ||||||
|  | 	int			(*bind)(struct usb_composite_dev *); | ||||||
|  | 	int			(*unbind)(struct usb_composite_dev *); | ||||||
|  |  | ||||||
|  | 	void			(*disconnect)(struct usb_composite_dev *); | ||||||
|  |  | ||||||
|  | 	/* global suspend hooks */ | ||||||
|  | 	void			(*suspend)(struct usb_composite_dev *); | ||||||
|  | 	void			(*resume)(struct usb_composite_dev *); | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | extern int usb_composite_register(struct usb_composite_driver *); | ||||||
|  | extern void usb_composite_unregister(struct usb_composite_driver *); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * struct usb_composite_device - represents one composite usb gadget | ||||||
|  |  * @gadget: read-only, abstracts the gadget's usb peripheral controller | ||||||
|  |  * @req: used for control responses; buffer is pre-allocated | ||||||
|  |  * @bufsiz: size of buffer pre-allocated in @req | ||||||
|  |  * @config: the currently active configuration | ||||||
|  |  * | ||||||
|  |  * One of these devices is allocated and initialized before the | ||||||
|  |  * associated device driver's bind() is called. | ||||||
|  |  * | ||||||
|  |  * OPEN ISSUE:  it appears that some WUSB devices will need to be | ||||||
|  |  * built by combining a normal (wired) gadget with a wireless one. | ||||||
|  |  * This revision of the gadget framework should probably try to make | ||||||
|  |  * sure doing that won't hurt too much. | ||||||
|  |  * | ||||||
|  |  * One notion for how to handle Wireless USB devices involves: | ||||||
|  |  * (a) a second gadget here, discovery mechanism TBD, but likely | ||||||
|  |  *     needing separate "register/unregister WUSB gadget" calls; | ||||||
|  |  * (b) updates to usb_gadget to include flags "is it wireless", | ||||||
|  |  *     "is it wired", plus (presumably in a wrapper structure) | ||||||
|  |  *     bandgroup and PHY info; | ||||||
|  |  * (c) presumably a wireless_ep wrapping a usb_ep, and reporting | ||||||
|  |  *     wireless-specific parameters like maxburst and maxsequence; | ||||||
|  |  * (d) configurations that are specific to wireless links; | ||||||
|  |  * (e) function drivers that understand wireless configs and will | ||||||
|  |  *     support wireless for (additional) function instances; | ||||||
|  |  * (f) a function to support association setup (like CBAF), not | ||||||
|  |  *     necessarily requiring a wireless adapter; | ||||||
|  |  * (g) composite device setup that can create one or more wireless | ||||||
|  |  *     configs, including appropriate association setup support; | ||||||
|  |  * (h) more, TBD. | ||||||
|  |  */ | ||||||
|  | struct usb_composite_dev { | ||||||
|  | 	struct usb_gadget		*gadget; | ||||||
|  | 	struct usb_request		*req; | ||||||
|  | 	unsigned			bufsiz; | ||||||
|  |  | ||||||
|  | 	struct usb_configuration	*config; | ||||||
|  |  | ||||||
|  | 	/* private: */ | ||||||
|  | 	/* internals */ | ||||||
|  | 	unsigned int			suspended:1; | ||||||
|  | 	struct usb_device_descriptor	desc; | ||||||
|  | 	struct list_head		configs; | ||||||
|  | 	struct usb_composite_driver	*driver; | ||||||
|  | 	u8				next_string_id; | ||||||
|  |  | ||||||
|  | 	/* the gadget driver won't enable the data pullup | ||||||
|  | 	 * while the deactivation count is nonzero. | ||||||
|  | 	 */ | ||||||
|  | 	unsigned			deactivations; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | extern int usb_string_id(struct usb_composite_dev *c); | ||||||
|  | extern int usb_string_ids_tab(struct usb_composite_dev *c, | ||||||
|  | 			      struct usb_string *str); | ||||||
|  | extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); | ||||||
|  |  | ||||||
|  | #endif	/* __LINUX_USB_COMPOSITE_H */ | ||||||
| @@ -411,6 +411,7 @@ struct usb_gadget_ops { | |||||||
|  |  | ||||||
| struct device { | struct device { | ||||||
| 	void		*driver_data;	/* data private to the driver */ | 	void		*driver_data;	/* data private to the driver */ | ||||||
|  | 	void            *device_data;   /* data private to the device */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -481,6 +482,11 @@ static inline void *get_gadget_data(struct usb_gadget *gadget) | |||||||
| 	return gadget->dev.driver_data; | 	return gadget->dev.driver_data; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev) | ||||||
|  | { | ||||||
|  | 	return container_of(dev, struct usb_gadget, dev); | ||||||
|  | } | ||||||
|  |  | ||||||
| /* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */ | /* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */ | ||||||
| #define gadget_for_each_ep(tmp, gadget) \ | #define gadget_for_each_ep(tmp, gadget) \ | ||||||
| 	list_for_each_entry(tmp, &(gadget)->ep_list, ep_list) | 	list_for_each_entry(tmp, &(gadget)->ep_list, ep_list) | ||||||
|   | |||||||
| @@ -26,7 +26,9 @@ | |||||||
|  |  | ||||||
| typedef struct SCSI_cmd_block{ | typedef struct SCSI_cmd_block{ | ||||||
| 	unsigned char		cmd[16];					/* command				   */ | 	unsigned char		cmd[16];					/* command				   */ | ||||||
| 	unsigned char		sense_buf[64];		/* for request sense */ | 	/* for request sense */ | ||||||
|  | 	unsigned char		sense_buf[64] | ||||||
|  | 		__attribute__((aligned(ARCH_DMA_MINALIGN))); | ||||||
| 	unsigned char		status;						/* SCSI Status			 */ | 	unsigned char		status;						/* SCSI Status			 */ | ||||||
| 	unsigned char		target;						/* Target ID				 */ | 	unsigned char		target;						/* Target ID				 */ | ||||||
| 	unsigned char		lun;							/* Target LUN        */ | 	unsigned char		lun;							/* Target LUN        */ | ||||||
|   | |||||||
| @@ -109,7 +109,9 @@ struct usb_device { | |||||||
| 	int epmaxpacketout[16];		/* OUTput endpoint specific maximums */ | 	int epmaxpacketout[16];		/* OUTput endpoint specific maximums */ | ||||||
|  |  | ||||||
| 	int configno;			/* selected config number */ | 	int configno;			/* selected config number */ | ||||||
| 	struct usb_device_descriptor descriptor; /* Device Descriptor */ | 	/* Device Descriptor */ | ||||||
|  | 	struct usb_device_descriptor descriptor | ||||||
|  | 		__attribute__((aligned(ARCH_DMA_MINALIGN))); | ||||||
| 	struct usb_config config; /* config descriptor */ | 	struct usb_config config; /* config descriptor */ | ||||||
|  |  | ||||||
| 	int have_langid;		/* whether string_langid is valid yet */ | 	int have_langid;		/* whether string_langid is valid yet */ | ||||||
|   | |||||||
| @@ -44,6 +44,25 @@ | |||||||
|  |  | ||||||
| #define ENOTSUPP	524	/* Operation is not supported */ | #define ENOTSUPP	524	/* Operation is not supported */ | ||||||
|  |  | ||||||
|  | #define BITS_PER_BYTE				8 | ||||||
|  | #define BITS_TO_LONGS(nr) \ | ||||||
|  | 	DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) | ||||||
|  | #define DECLARE_BITMAP(name, bits) \ | ||||||
|  | 	unsigned long name[BITS_TO_LONGS(bits)] | ||||||
|  |  | ||||||
|  | #define small_const_nbits(nbits) \ | ||||||
|  | 	(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) | ||||||
|  |  | ||||||
|  | static inline void bitmap_zero(unsigned long *dst, int nbits) | ||||||
|  | { | ||||||
|  | 	if (small_const_nbits(nbits)) | ||||||
|  | 		*dst = 0UL; | ||||||
|  | 	else { | ||||||
|  | 		int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); | ||||||
|  | 		memset(dst, 0, len); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| #define dma_cache_maint(addr, size, mode) cache_flush() | #define dma_cache_maint(addr, size, mode) cache_flush() | ||||||
| void cache_flush(void); | void cache_flush(void); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ | |||||||
|  |  | ||||||
| #include <asm/errno.h> | #include <asm/errno.h> | ||||||
| #include <linux/usb/ch9.h> | #include <linux/usb/ch9.h> | ||||||
|  | #include <usbdescriptors.h> | ||||||
| #include <linux/usb/gadget.h> | #include <linux/usb/gadget.h> | ||||||
| #include <linux/list.h> | #include <linux/list.h> | ||||||
| #include <usb/lin_gadget_compat.h> | #include <usb/lin_gadget_compat.h> | ||||||
| @@ -111,54 +112,6 @@ extern struct s3c_udc *the_controller; | |||||||
| #define ep_index(EP) ((EP)->bEndpointAddress&0xF) | #define ep_index(EP) ((EP)->bEndpointAddress&0xF) | ||||||
| #define ep_maxpacket(EP) ((EP)->ep.maxpacket) | #define ep_maxpacket(EP) ((EP)->ep.maxpacket) | ||||||
|  |  | ||||||
| /*-------------------------------------------------------------------------*/ |  | ||||||
| /* #define DEBUG_UDC */ |  | ||||||
| #ifdef DEBUG_UDC |  | ||||||
| #define DBG(stuff...)		printf("udc: " stuff) |  | ||||||
| #else |  | ||||||
| #define DBG(stuff...)		do {} while (0) |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifdef DEBUG_S3C_UDC_SETUP |  | ||||||
| #define DEBUG_SETUP(fmt, args...) printk(fmt, ##args) |  | ||||||
| #else |  | ||||||
| #define DEBUG_SETUP(fmt, args...) do {} while (0) |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifdef DEBUG_S3C_UDC_EP0 |  | ||||||
| #define DEBUG_EP0(fmt, args...) printk(fmt, ##args) |  | ||||||
| #else |  | ||||||
| #define DEBUG_EP0(fmt, args...) do {} while (0) |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifdef DEBUG_S3C_UDC_ISR |  | ||||||
| #define DEBUG_ISR	1 |  | ||||||
| #else |  | ||||||
| #define DEBUG_ISR	0 |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifdef DEBUG_S3C_UDC_OUT_EP |  | ||||||
| #define DEBUG_OUT_EP(fmt, args...) printk(fmt, ##args) |  | ||||||
| #else |  | ||||||
| #define DEBUG_OUT_EP(fmt, args...) do {} while (0) |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifdef DEBUG_S3C_UDC_IN_EP |  | ||||||
| #define DEBUG_IN_EP	1 |  | ||||||
| #else |  | ||||||
| #define DEBUG_IN_EP	0 |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #if defined(DEBUG_S3C_UDC_SETUP) || defined(DEBUG_S3C_UDC_EP0) || \ |  | ||||||
| 	defined(DEBUG_S3C_UDC_ISR) || defined(DEBUG_S3C_UDC_OUT_EP) || \ |  | ||||||
| 	defined(DEBUG_S3C_UDC_IN_EP) || defined(DEBUG_S3C_UDC) |  | ||||||
| #define DEBUG |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #define ERR(stuff...)		printf("ERR udc: " stuff) |  | ||||||
| #define WARN(stuff...)		printf("WARNING udc: " stuff) |  | ||||||
| #define INFO(stuff...)		printf("INFO udc: " stuff) |  | ||||||
|  |  | ||||||
| extern void otg_phy_init(struct s3c_udc *dev); | extern void otg_phy_init(struct s3c_udc *dev); | ||||||
| extern void otg_phy_off(struct s3c_udc *dev); | extern void otg_phy_off(struct s3c_udc *dev); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user