[coreboot] [v2] r4239 - in trunk/payloads/libpayload/drivers: . usb

svn at coreboot.org svn at coreboot.org
Thu Apr 30 18:46:12 CEST 2009


Author: stepan
Date: 2009-04-30 18:46:12 +0200 (Thu, 30 Apr 2009)
New Revision: 4239

Modified:
   trunk/payloads/libpayload/drivers/options.c
   trunk/payloads/libpayload/drivers/serial.c
   trunk/payloads/libpayload/drivers/usb/uhci.c
   trunk/payloads/libpayload/drivers/usb/usb.c
   trunk/payloads/libpayload/drivers/usb/usbhid.c
   trunk/payloads/libpayload/drivers/usb/usbmsc.c
Log:
Some driver fixes for libpayload:
- fix minor bug in serial driver.
- latest USB stack fixes
- fix dead store in options.c

Signed-off-by: Stefan Reinauer <stepan at coresystems.de>
Acked-by: Patrick Georgi <patrick.georgi at coresystems.de>



Modified: trunk/payloads/libpayload/drivers/options.c
===================================================================
--- trunk/payloads/libpayload/drivers/options.c	2009-04-30 13:58:42 UTC (rev 4238)
+++ trunk/payloads/libpayload/drivers/options.c	2009-04-30 16:46:12 UTC (rev 4239)
@@ -55,8 +55,6 @@
 	u32 addr, bit;
 	u8 reg8;
 
-	value = valptr;
-
 	/* Convert to byte borders */
 	addr=(bitnum / 8);
 	bit=(bitnum % 8);
@@ -85,7 +83,6 @@
 	int len = strnlen(name, CMOS_MAX_NAME_LENGTH);
 	
 	/* cmos entries are located right after the option table */
-	cmos_entry=(struct cb_cmos_entries*)((unsigned char *)option_table + option_table->header_length);
 
 	for (   cmos_entry = (struct cb_cmos_entries*)((unsigned char *)option_table + option_table->header_length);
 		cmos_entry->tag == CB_TAG_OPTION;

Modified: trunk/payloads/libpayload/drivers/serial.c
===================================================================
--- trunk/payloads/libpayload/drivers/serial.c	2009-04-30 13:58:42 UTC (rev 4238)
+++ trunk/payloads/libpayload/drivers/serial.c	2009-04-30 16:46:12 UTC (rev 4239)
@@ -55,7 +55,7 @@
 	outb(DIVISOR(speed) >> 8 & 0xFF, port + 1);
 
 	/* Restore the previous value of the divisor. */
-	outb(reg &= ~0x80, port + 0x03);
+	outb(reg & ~0x80, port + 0x03);
 }
 
 static struct console_input_driver consin = {

Modified: trunk/payloads/libpayload/drivers/usb/uhci.c
===================================================================
--- trunk/payloads/libpayload/drivers/usb/uhci.c	2009-04-30 13:58:42 UTC (rev 4238)
+++ trunk/payloads/libpayload/drivers/usb/uhci.c	2009-04-30 16:46:12 UTC (rev 4239)
@@ -63,7 +63,23 @@
 static void
 td_dump (td_t *td)
 {
-	printf ("%x packet (at %lx) to %x.%x failed\n", td->pid,
+	char td_value[3];
+	char *td_type;
+	switch (td->pid) {
+		case SETUP:
+			td_type="SETUP";
+			break;
+		case IN:
+			td_type="IN";
+			break;
+		case OUT:
+			td_type="OUT";
+			break;
+		default:
+			sprintf(td_value, "%x", td->pid);
+			td_type=td_value;
+	}
+	printf ("%s packet (at %lx) to %x.%x failed\n", td_type,
 		virt_to_phys (td), td->dev_addr, td->endp);
 	printf ("td (counter at %x) returns: ", td->counter);
 	printf (" bitstuff err: %x, ", td->status_bitstuff_err);
@@ -493,6 +509,7 @@
 	qh_t *qh = memalign(16, sizeof(qh_t));
 
 	qh->elementlinkptr.ptr = virt_to_phys(tds);
+	qh->elementlinkptr.queue_head = 0;
 	qh->elementlinkptr.terminate = 0;
 
 	intr_q *q = malloc(sizeof(intr_q));

Modified: trunk/payloads/libpayload/drivers/usb/usb.c
===================================================================
--- trunk/payloads/libpayload/drivers/usb/usb.c	2009-04-30 13:58:42 UTC (rev 4238)
+++ trunk/payloads/libpayload/drivers/usb/usb.c	2009-04-30 16:46:12 UTC (rev 4239)
@@ -281,7 +281,16 @@
 		int num = cd->bNumInterfaces;
 		interface_descriptor_t *current = interface;
 		printf ("device has %x interfaces\n", num);
-		num = (num > 5) ? 5 : num;
+		if (num>1)
+			printf ("NOTICE: This driver defaults to using the first interface.\n"
+				"This might be the wrong choice and lead to limited functionality\n"
+				"of the device. Please report such a case to coreboot at coreboot.org\n"
+				"as you might be the first.\n");
+		/* we limit to the first interface, as there was no need to
+		   implement something else for the time being. If you need
+		   it, see the SetInterface and GetInterface functions in
+		   the USB specification, and adapt appropriately. */
+		num = (num > 1) ? 1 : num;
 		for (i = 0; i < num; i++) {
 			int j;
 			printf (" #%x has %x endpoints, interface %x:%x, protocol %x\n", current->bInterfaceNumber, current->bNumEndpoints, current->bInterfaceClass, current->bInterfaceSubClass, current->bInterfaceProtocol);

Modified: trunk/payloads/libpayload/drivers/usb/usbhid.c
===================================================================
--- trunk/payloads/libpayload/drivers/usb/usbhid.c	2009-04-30 13:58:42 UTC (rev 4238)
+++ trunk/payloads/libpayload/drivers/usb/usbhid.c	2009-04-30 16:46:12 UTC (rev 4239)
@@ -178,7 +178,7 @@
 			dev->destroy = usb_hid_destroy;
 			dev->poll = usb_hid_poll;
 			int i;
-			for (i = 1; i <= dev->num_endp; i++) {
+			for (i = 0; i <= dev->num_endp; i++) {
 				if (dev->endpoints[i].endpoint == 0)
 					continue;
 				if (dev->endpoints[i].type != INTERRUPT)
@@ -187,6 +187,7 @@
 					continue;
 				break;
 			}
+			printf ("  found endpoint %x for interrupt-in\n", i);
 			/* 20 buffers of 8 bytes, for every 10 msecs */
 			HID_INST(dev)->queue = dev->controller->create_intr_queue (&dev->endpoints[i], 8, 20, 10);
 			count = 0;

Modified: trunk/payloads/libpayload/drivers/usb/usbmsc.c
===================================================================
--- trunk/payloads/libpayload/drivers/usb/usbmsc.c	2009-04-30 13:58:42 UTC (rev 4238)
+++ trunk/payloads/libpayload/drivers/usb/usbmsc.c	2009-04-30 16:46:12 UTC (rev 4239)
@@ -299,6 +299,8 @@
 	memset (&cb, 0, sizeof (cb));
 	cb.command = 0x25;	// read capacity
 	u8 buf[8];
+
+	printf ("Reading capacity of mass storage device.\n");
 	int count = 0;
 	while ((count++ < 20)
 	       &&
@@ -306,8 +308,8 @@
 		(dev, cbw_direction_data_in, (u8 *) &cb, sizeof (cb), buf,
 		 8) == 1));
 	if (count >= 20) {
-		// still not successful, assume 2tb in 512byte sectors, which is just the same garbage as any other number, but probably reasonable.
-		printf ("assuming 2TB in 512byte sectors as READ CAPACITY didn't answer.\n");
+		// still not successful, assume 2tb in 512byte sectors, which is just the same garbage as any other number, but probably more usable.
+		printf ("Assuming 2TB in 512byte sectors as READ CAPACITY didn't answer.\n");
 		MSC_INST (dev)->numblocks = 0xffffffff;
 		MSC_INST (dev)->blocksize = 512;
 	} else {





More information about the coreboot mailing list