r1364 - trunk/src/target/u-boot/patches

laforge at sita.openmoko.org laforge at sita.openmoko.org
Wed Mar 14 20:54:35 CET 2007


Author: laforge
Date: 2007-03-14 20:54:34 +0100 (Wed, 14 Mar 2007)
New Revision: 1364

Added:
   trunk/src/target/u-boot/patches/neo1973-chargefast.patch
   trunk/src/target/u-boot/patches/usbdcore-multiple_configs.patch
Modified:
   trunk/src/target/u-boot/patches/series
Log:
Add support for two USB configurations, one of which is 500mA and the other one is 100mA.  Once the host issues SET_CONFIGURATION, the apropriate charging mode is selected


Added: trunk/src/target/u-boot/patches/neo1973-chargefast.patch
===================================================================
--- trunk/src/target/u-boot/patches/neo1973-chargefast.patch	2007-03-14 19:53:40 UTC (rev 1363)
+++ trunk/src/target/u-boot/patches/neo1973-chargefast.patch	2007-03-14 19:54:34 UTC (rev 1364)
@@ -0,0 +1,282 @@
+Index: u-boot/drivers/usbtty.c
+===================================================================
+--- u-boot.orig/drivers/usbtty.c	2007-03-14 20:37:15.000000000 +0100
++++ u-boot/drivers/usbtty.c	2007-03-14 20:49:03.000000000 +0100
+@@ -66,7 +66,7 @@
+ /*
+  * Defines
+  */
+-#define NUM_CONFIGS    1
++#define NUM_CONFIGS    2
+ #define MAX_INTERFACES 2
+ #define NUM_ENDPOINTS  3
+ #define ACM_TX_ENDPOINT 3
+@@ -192,8 +192,7 @@
+ #endif
+     			.bConfigurationValue = 1,
+ 			.iConfiguration = STR_CONFIG,
+-			.bmAttributes = 
+-				BMATTRIBUTE_SELF_POWERED|BMATTRIBUTE_RESERVED,
++			.bmAttributes = BMATTRIBUTE_RESERVED,
+ 			.bMaxPower = USBTTY_MAXPOWER
+ 		},
+ 		/* Interface 1 */
+@@ -294,6 +293,120 @@
+ 		.func_dfu = DFU_FUNC_DESC,
+ #endif
+ 	},
++	{
++		.configuration_desc ={
++			.bLength = 
++				sizeof(struct usb_configuration_descriptor),
++    			.bDescriptorType = USB_DT_CONFIG,
++			.wTotalLength =	 
++				cpu_to_le16(sizeof(struct acm_config_desc)
++#ifdef CONFIG_USBD_DFU
++					    - sizeof(struct usb_interface_descriptor)
++					    - sizeof(struct usb_dfu_func_descriptor)
++#endif
++					   ),
++	    		.bNumInterfaces = NUM_ACM_INTERFACES,
++    			.bConfigurationValue = 2,
++			.iConfiguration = STR_CONFIG,
++			.bmAttributes = BMATTRIBUTE_RESERVED,
++			.bMaxPower = 50, /* 100mA */
++		},
++		/* Interface 1 */
++		.interface_desc = {
++			.bLength  = sizeof(struct usb_interface_descriptor),
++			.bDescriptorType = USB_DT_INTERFACE,
++			.bInterfaceNumber = 0,
++			.bAlternateSetting = 0,
++			.bNumEndpoints = 0x01,
++			.bInterfaceClass = 
++				COMMUNICATIONS_INTERFACE_CLASS_CONTROL,
++			.bInterfaceSubClass = COMMUNICATIONS_ACM_SUBCLASS,
++			.bInterfaceProtocol = COMMUNICATIONS_V25TER_PROTOCOL,
++			.iInterface = STR_CTRL_INTERFACE,
++		},
++		.usb_class_header = {
++			.bFunctionLength	= 
++				sizeof(struct usb_class_header_function_descriptor),
++			.bDescriptorType	= CS_INTERFACE,	
++			.bDescriptorSubtype	= USB_ST_HEADER,
++			.bcdCDC	= cpu_to_le16(110),
++		},
++		.usb_class_call_mgt = {
++			.bFunctionLength	= 
++				sizeof(struct usb_class_call_management_descriptor),
++			.bDescriptorType	= CS_INTERFACE,
++			.bDescriptorSubtype	= USB_ST_CMF,
++			.bmCapabilities		= 0x00,	
++			.bDataInterface		= 0x01,	
++		},
++		.usb_class_acm = {
++			.bFunctionLength	= 
++				sizeof(struct usb_class_abstract_control_descriptor),
++			.bDescriptorType	= CS_INTERFACE,
++			.bDescriptorSubtype	= USB_ST_ACMF,	
++			.bmCapabilities		= 0x00,	
++		},
++		.usb_class_union = {
++			.bFunctionLength	= 	
++				sizeof(struct usb_class_union_function_descriptor),
++			.bDescriptorType	= CS_INTERFACE,
++			.bDescriptorSubtype	= USB_ST_UF,
++			.bMasterInterface	= 0x00,	
++			.bSlaveInterface0	= 0x01,	
++		},
++		.notification_endpoint = {
++			.bLength =		
++				sizeof(struct usb_endpoint_descriptor),
++			.bDescriptorType	= USB_DT_ENDPOINT,
++			.bEndpointAddress	= 0x01 | USB_DIR_IN,
++			.bmAttributes		= USB_ENDPOINT_XFER_INT,
++			.wMaxPacketSize		
++				= cpu_to_le16(CONFIG_USBD_SERIAL_INT_PKTSIZE),
++			.bInterval		= 0xFF,
++		},
++
++		/* Interface 2 */
++		.data_class_interface = {
++			.bLength		= 
++				sizeof(struct usb_interface_descriptor),
++			.bDescriptorType	= USB_DT_INTERFACE,
++			.bInterfaceNumber	= 0x01,
++			.bAlternateSetting	= 0x00,
++			.bNumEndpoints		= 0x02,
++			.bInterfaceClass	= 
++				COMMUNICATIONS_INTERFACE_CLASS_DATA,
++			.bInterfaceSubClass	= DATA_INTERFACE_SUBCLASS_NONE,
++			.bInterfaceProtocol	= DATA_INTERFACE_PROTOCOL_NONE,
++			.iInterface		= STR_DATA_INTERFACE,
++		},
++		.data_endpoints = {
++			{
++				.bLength		= 
++					sizeof(struct usb_endpoint_descriptor),
++				.bDescriptorType	= USB_DT_ENDPOINT,
++				.bEndpointAddress	= 0x02 | USB_DIR_OUT,
++				.bmAttributes		= 
++					USB_ENDPOINT_XFER_BULK,
++				.wMaxPacketSize		= 
++					cpu_to_le16(CONFIG_USBD_SERIAL_BULK_PKTSIZE),
++				.bInterval		= 0xFF,
++			},
++			{
++				.bLength		= 
++					sizeof(struct usb_endpoint_descriptor),
++				.bDescriptorType	= USB_DT_ENDPOINT,
++				.bEndpointAddress	= 0x03 | USB_DIR_IN,
++				.bmAttributes		= 
++					USB_ENDPOINT_XFER_BULK,
++				.wMaxPacketSize		= 
++					cpu_to_le16(CONFIG_USBD_SERIAL_BULK_PKTSIZE),
++				.bInterval		= 0xFF,
++			},
++		},
++		/* We don't add the DFU functional descriptor here since we only
++		 * want to do DFU in the high-current charging mode for safety reasons */
++	},
++
+ };	
+ 
+ static struct rs232_emu rs232_desc={
+@@ -330,8 +443,7 @@
+ 			.bNumInterfaces = NUM_GSERIAL_INTERFACES,
+ 			.bConfigurationValue = 1,
+ 			.iConfiguration = STR_CONFIG,
+-			.bmAttributes = 
+-				BMATTRIBUTE_SELF_POWERED|BMATTRIBUTE_RESERVED,
++			.bmAttributes = BMATTRIBUTE_RESERVED,
+ 			.bMaxPower = USBTTY_MAXPOWER
+ 		},
+ 		.interface_desc = {
+@@ -384,6 +496,68 @@
+ 			},
+ 		},
+ 	},
++	{
++		.configuration_desc ={
++			.bLength = sizeof(struct usb_configuration_descriptor),
++			.bDescriptorType = USB_DT_CONFIG,
++			.wTotalLength =	 
++				cpu_to_le16(sizeof(struct gserial_config_desc)),
++			.bNumInterfaces = NUM_GSERIAL_INTERFACES,
++			.bConfigurationValue = 1,
++			.iConfiguration = STR_CONFIG,
++			.bmAttributes = BMATTRIBUTE_RESERVED,
++			.bMaxPower = 50
++		},
++		.interface_desc = {
++			{
++				.bLength  = 
++					sizeof(struct usb_interface_descriptor),
++				.bDescriptorType = USB_DT_INTERFACE,
++				.bInterfaceNumber = 0,
++				.bAlternateSetting = 0,
++				.bNumEndpoints = NUM_ENDPOINTS,
++				.bInterfaceClass = 
++					COMMUNICATIONS_INTERFACE_CLASS_VENDOR,
++				.bInterfaceSubClass = 
++					COMMUNICATIONS_NO_SUBCLASS,
++				.bInterfaceProtocol = 
++					COMMUNICATIONS_NO_PROTOCOL,
++				.iInterface = STR_DATA_INTERFACE
++			},
++  		},
++		.data_endpoints  = {
++			{
++				.bLength =		
++					sizeof(struct usb_endpoint_descriptor),
++				.bDescriptorType =	USB_DT_ENDPOINT,
++				.bEndpointAddress =	0x01 | USB_DIR_OUT,
++				.bmAttributes =		USB_ENDPOINT_XFER_BULK,
++				.wMaxPacketSize =	
++					cpu_to_le16(CONFIG_USBD_SERIAL_OUT_PKTSIZE),
++				.bInterval=		0xFF,
++			},
++			{
++				.bLength =		
++					sizeof(struct usb_endpoint_descriptor),
++				.bDescriptorType =	USB_DT_ENDPOINT,
++				.bEndpointAddress =	0x02 | USB_DIR_IN,
++				.bmAttributes =		USB_ENDPOINT_XFER_BULK,
++				.wMaxPacketSize = 	
++					cpu_to_le16(CONFIG_USBD_SERIAL_IN_PKTSIZE),
++				.bInterval = 		0xFF,
++			},
++			{
++				.bLength = 		
++					sizeof(struct usb_endpoint_descriptor),
++				.bDescriptorType =	USB_DT_ENDPOINT,
++				.bEndpointAddress =	0x03 | USB_DIR_IN,
++				.bmAttributes =		USB_ENDPOINT_XFER_INT,
++    				.wMaxPacketSize =	
++					cpu_to_le16(CONFIG_USBD_SERIAL_INT_PKTSIZE),
++				.bInterval =		0xFF,
++			},
++		},
++	},
+ };
+ 
+ /*
+@@ -679,12 +853,14 @@
+ 	bus_instance->maxpacketsize = 64;
+ 	bus_instance->serial_number_str = serial_number;
+ 
+-	/* configuration instance */
+-	memset (config_instance, 0,
+-		sizeof (struct usb_configuration_instance));
+-	config_instance->interfaces = interface_count;
+-	config_instance->configuration_descriptor = configuration_descriptor;
+-	config_instance->interface_instance_array = interface_instance;
++	/* configuration instances */
++	for (i = 0; i < NUM_CONFIGS; i++) {
++		memset(&config_instance[i], 0, sizeof(config_instance));
++		config_instance[i].interfaces = interface_count;
++		/* FIXME: this breaks for the non-ACM case */
++		config_instance[i].configuration_descriptor = &acm_configuration_descriptors[i];
++		config_instance[i].interface_instance_array = interface_instance;
++	}
+ 
+ 	/* interface instance */
+ 	memset (interface_instance, 0,
+@@ -1043,9 +1219,23 @@
+ 		usbtty_configured_flag = 0;
+ 		break;
+ 	case DEVICE_CONFIGURED:
++		printf("DEVICE_CONFIGURED: %u\n", device->configuration);
++#if 1
++		/* FIXME: This needs to be device specific */
++		if (device->configuration == 1)
++			pcf50606_charge_autofast(1);
++		else
++			pcf50606_charge_autofast(0);
++#endif
+ 		usbtty_configured_flag = 1;
+ 		break;
+-
++	case DEVICE_DE_CONFIGURED:
++		printf("DEVICE_DE_CONFIGURED\n");
++#if 1
++		/* FIXME: This needs to be device specific */
++		pcf50606_charge_autofast(0);
++#endif
++		break;
+ 	case DEVICE_ADDRESS_ASSIGNED:
+ 		usbtty_init_endpoints ();
+ 
+Index: u-boot/drivers/usbtty.h
+===================================================================
+--- u-boot.orig/drivers/usbtty.h	2007-03-14 20:37:15.000000000 +0100
++++ u-boot/drivers/usbtty.h	2007-03-14 20:37:41.000000000 +0100
+@@ -60,7 +60,7 @@
+ #define USBTTY_DEVICE_CLASS	COMMUNICATIONS_DEVICE_CLASS
+ 
+ #define USBTTY_BCD_DEVICE	0x00
+-#define USBTTY_MAXPOWER  	0x00
++#define USBTTY_MAXPOWER  	250	/* 500mA */
+ 
+ #define STR_LANG		0x00
+ #define STR_MANUFACTURER	0x01

Modified: trunk/src/target/u-boot/patches/series
===================================================================
--- trunk/src/target/u-boot/patches/series	2007-03-14 19:53:40 UTC (rev 1363)
+++ trunk/src/target/u-boot/patches/series	2007-03-14 19:54:34 UTC (rev 1364)
@@ -65,3 +65,5 @@
 uboot-neo1973-defaultenv.patch
 uboot-nand-markbad-reallybad.patch
 mmc-fixes.patch
+usbdcore-multiple_configs.patch
+neo1973-chargefast.patch

Added: trunk/src/target/u-boot/patches/usbdcore-multiple_configs.patch
===================================================================
--- trunk/src/target/u-boot/patches/usbdcore-multiple_configs.patch	2007-03-14 19:53:40 UTC (rev 1363)
+++ trunk/src/target/u-boot/patches/usbdcore-multiple_configs.patch	2007-03-14 19:54:34 UTC (rev 1364)
@@ -0,0 +1,63 @@
+This patch fixes bugs in usbdcore*.c related to the use of devices
+with multiple configurations.
+
+The original code made mistakes about the meaning of configuration value and
+configuration index, and the resulting off-by-one errors resulted in:
+
+* SET_CONFIGURATION always selected the first configuration, no matter what
+  wValue is being passed.
+* GET_DESCRIPTOR/CONFIGURATION always returned the descriptor for the first
+  configuration (index 0).
+
+Signed-off-by: Harald Welte <laforge at openmoko.org>
+
+Index: u-boot/drivers/usbdcore_ep0.c
+===================================================================
+--- u-boot.orig/drivers/usbdcore_ep0.c	2007-03-14 20:29:05.000000000 +0100
++++ u-boot/drivers/usbdcore_ep0.c	2007-03-14 20:29:06.000000000 +0100
+@@ -233,8 +233,8 @@
+ 				return -1;
+ 			}
+ 			/*dbg_ep0(2, "%d %d", index, device_descriptor->bNumConfigurations); */
+-			if (index > device_descriptor->bNumConfigurations) {
+-				dbg_ep0 (0, "index too large: %d > %d", index,
++			if (index >= device_descriptor->bNumConfigurations) {
++				dbg_ep0 (0, "index too large: %d >= %d", index,
+ 					 device_descriptor->
+ 					 bNumConfigurations);
+ 				return -1;
+@@ -593,13 +593,8 @@
+ 
+ 		case USB_REQ_SET_CONFIGURATION:
+ 			/* c.f. 9.4.7 - the top half of wValue is reserved */
+-			/* */
+-			if ((device->configuration =
+-			     le16_to_cpu (request->wValue) & 0x7f) != 0) {
+-				/* c.f. 9.4.7 - zero is the default or addressed state, in our case this */
+-				/* is the same is configuration zero */
+-				device->configuration = 0;	/* TBR - ?????? */
+-			}
++			device->configuration = le16_to_cpu(request->wValue) & 0xff;
++
+ 			/* reset interface and alternate settings */
+ 			device->interface = device->alternate = 0;
+ 
+Index: u-boot/drivers/usbdcore.c
+===================================================================
+--- u-boot.orig/drivers/usbdcore.c	2007-03-14 20:29:05.000000000 +0100
++++ u-boot/drivers/usbdcore.c	2007-03-14 20:37:37.000000000 +0100
+@@ -147,12 +147,9 @@
+ static struct usb_configuration_instance *usbd_device_configuration_instance (struct usb_device_instance *device,
+ 		unsigned int port, unsigned int configuration)
+ {
+-	/* XXX */
+-	configuration = configuration ? configuration - 1 : 0;
+-
+-	if (configuration >= device->configurations) {
++	if (configuration >= device->configurations)
+ 		return NULL;
+-	}
++
+ 	return device->configuration_instance_array + configuration;
+ }
+ 





More information about the commitlog mailing list