libpayload: Use usb_debug() to show USB messages

Previously printf()'s were used to show USB messages
which results in lots of USB information being shown
when it isn't needed. This will now use the usb_debug()
printing funtion that already exists in usb.h.

Change-Id: I2199814de3327417417eb2e26a660f4a5557cb9f
Signed-off-by: Dave Frodin <dave.frodin@se-eng.com>
Reviewed-on: http://review.coreboot.org/2044
Tested-by: build bot (Jenkins)
Reviewed-by: Anton Kochkov <anton.kochkov@gmail.com>
This commit is contained in:
Dave Frodin 2012-12-11 13:08:07 -07:00 committed by Anton Kochkov
parent 8024b65550
commit 6bf11cf50c
9 changed files with 54 additions and 54 deletions

View File

@ -206,7 +206,7 @@ static int wait_for_tds(qtd_t *head)
&& timeout--) && timeout--)
udelay(50); udelay(50);
if (timeout < 0) { if (timeout < 0) {
printf("Error: ehci: queue transfer " usb_debug("Error: ehci: queue transfer "
"processing timed out.\n"); "processing timed out.\n");
return 1; return 1;
} }
@ -362,7 +362,7 @@ static int ehci_control (usbdev_t *dev, direction_t dir, int drlen, void *devreq
(EHCI_SETUP << QTD_PID_SHIFT) | (EHCI_SETUP << QTD_PID_SHIFT) |
(3 << QTD_CERR_SHIFT); (3 << QTD_CERR_SHIFT);
if (fill_td(cur, devreq, drlen) != drlen) { if (fill_td(cur, devreq, drlen) != drlen) {
printf("ERROR: couldn't send the entire device request\n"); usb_debug("ERROR: couldn't send the entire device request\n");
} }
qtd_t *next = memalign(32, sizeof(qtd_t)); qtd_t *next = memalign(32, sizeof(qtd_t));
cur->next_qtd = virt_to_phys(next); cur->next_qtd = virt_to_phys(next);
@ -379,7 +379,7 @@ static int ehci_control (usbdev_t *dev, direction_t dir, int drlen, void *devreq
(((dir == OUT)?EHCI_OUT:EHCI_IN) << QTD_PID_SHIFT) | (((dir == OUT)?EHCI_OUT:EHCI_IN) << QTD_PID_SHIFT) |
(3 << QTD_CERR_SHIFT); (3 << QTD_CERR_SHIFT);
if (fill_td(cur, data, dalen) != dalen) { if (fill_td(cur, data, dalen) != dalen) {
printf("ERROR: couldn't send the entire control payload\n"); usb_debug("ERROR: couldn't send the entire control payload\n");
} }
next = memalign(32, sizeof(qtd_t)); next = memalign(32, sizeof(qtd_t));
cur->next_qtd = virt_to_phys(next); cur->next_qtd = virt_to_phys(next);
@ -556,7 +556,7 @@ static void *ehci_create_intr_queue(
} }
} }
if (nothing_placed) { if (nothing_placed) {
printf("Error: Failed to place ehci interrupt queue head " usb_debug("Error: Failed to place ehci interrupt queue head "
"into periodic schedule: no space left\n"); "into periodic schedule: no space left\n");
ehci_destroy_intr_queue(ep, intrq); ehci_destroy_intr_queue(ep, intrq);
return NULL; return NULL;

View File

@ -107,7 +107,7 @@ ehci_rh_scanport (usbdev_t *dev, int port)
while ((RH_INST(dev)->ports[port] & P_PORT_RESET) && timeout--) while ((RH_INST(dev)->ports[port] & P_PORT_RESET) && timeout--)
udelay(100); udelay(100);
if (RH_INST(dev)->ports[port] & P_PORT_RESET) { if (RH_INST(dev)->ports[port] & P_PORT_RESET) {
printf("Error: ehci_rh: port reset timed out.\n"); usb_debug("Error: ehci_rh: port reset timed out.\n");
return; return;
} }

View File

@ -130,7 +130,7 @@ ohci_init (pcidev_t addr)
* BASE ADDRESS only [31-12] bits. All other usually 0, but not all */ * BASE ADDRESS only [31-12] bits. All other usually 0, but not all */
controller->reg_base = pci_read_config32 (controller->bus_address, 0x10) & 0xfffff000; // OHCI mandates MMIO, so bit 0 is clear controller->reg_base = pci_read_config32 (controller->bus_address, 0x10) & 0xfffff000; // OHCI mandates MMIO, so bit 0 is clear
OHCI_INST (controller)->opreg = (opreg_t*)phys_to_virt(controller->reg_base); OHCI_INST (controller)->opreg = (opreg_t*)phys_to_virt(controller->reg_base);
printf("OHCI Version %x.%x\n", (OHCI_INST (controller)->opreg->HcRevision >> 4) & 0xf, OHCI_INST (controller)->opreg->HcRevision & 0xf); usb_debug("OHCI Version %x.%x\n", (OHCI_INST (controller)->opreg->HcRevision >> 4) & 0xf, OHCI_INST (controller)->opreg->HcRevision & 0xf);
if ((OHCI_INST (controller)->opreg->HcControl & HostControllerFunctionalStateMask) == USBReset) { if ((OHCI_INST (controller)->opreg->HcControl & HostControllerFunctionalStateMask) == USBReset) {
/* cold boot */ /* cold boot */
@ -245,7 +245,7 @@ wait_for_ed(usbdev_t *dev, ed_t *head, int pages)
mdelay(1); mdelay(1);
} }
if (timeout < 0) if (timeout < 0)
printf("Error: ohci: endpoint " usb_debug("Error: ohci: endpoint "
"descriptor processing timed out.\n"); "descriptor processing timed out.\n");
/* Clear the done queue. */ /* Clear the done queue. */
ohci_process_done_queue(OHCI_INST(dev->controller), 1); ohci_process_done_queue(OHCI_INST(dev->controller), 1);
@ -609,7 +609,7 @@ ohci_create_intr_queue(endpoint_t *const ep, const int reqsize,
} }
} }
if (nothing_placed) { if (nothing_placed) {
printf("Error: Failed to place ohci interrupt endpoint " usb_debug("Error: Failed to place ohci interrupt endpoint "
"descriptor into periodic table: no space left\n"); "descriptor into periodic table: no space left\n");
ohci_destroy_intr_queue(ep, intrq); ohci_destroy_intr_queue(ep, intrq);
return NULL; return NULL;

View File

@ -532,7 +532,7 @@ uhci_create_intr_queue (endpoint_t *ep, int reqsize, int reqcount, int reqtiming
} }
} }
if (nothing_placed) { if (nothing_placed) {
printf("Error: Failed to place UHCI interrupt queue " usb_debug("Error: Failed to place UHCI interrupt queue "
"head into framelist: no space left\n"); "head into framelist: no space left\n");
uhci_destroy_intr_queue(ep, q); uhci_destroy_intr_queue(ep, q);
return NULL; return NULL;

View File

@ -286,7 +286,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
(device_to_host, standard_type, dev_recp), 1, 0, 0); (device_to_host, standard_type, dev_recp), 1, 0, 0);
dd = (device_descriptor_t *) dev->descriptor; dd = (device_descriptor_t *) dev->descriptor;
printf ("* found device (0x%04x:0x%04x, USB %x.%x)", usb_debug ("* found device (0x%04x:0x%04x, USB %x.%x)",
dd->idVendor, dd->idProduct, dd->idVendor, dd->idProduct,
dd->bcdUSB >> 8, dd->bcdUSB & 0xff); dd->bcdUSB >> 8, dd->bcdUSB & 0xff);
dev->quirks = usb_quirk_check(dd->idVendor, dd->idProduct); dev->quirks = usb_quirk_check(dd->idVendor, dd->idProduct);
@ -294,7 +294,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
usb_debug ("\ndevice has %x configurations\n", dd->bNumConfigurations); usb_debug ("\ndevice has %x configurations\n", dd->bNumConfigurations);
if (dd->bNumConfigurations == 0) { if (dd->bNumConfigurations == 0) {
/* device isn't usable */ /* device isn't usable */
printf ("... no usable configuration!\n"); usb_debug ("... no usable configuration!\n");
dev->address = 0; dev->address = 0;
return -1; return -1;
} }
@ -317,7 +317,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
num = interfaces; num = interfaces;
} else { } else {
printf ("\nNOTICE: This driver defaults to using the first interface.\n" usb_debug ("\nNOTICE: This driver defaults to using the first interface.\n"
"This might be the wrong choice and lead to limited functionality\n" "This might be the wrong choice and lead to limited functionality\n"
"of the device. Please report such a case to coreboot@coreboot.org\n" "of the device. Please report such a case to coreboot@coreboot.org\n"
"as you might be the first.\n"); "as you might be the first.\n");
@ -390,16 +390,16 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
wireless_device = 0xe0, wireless_device = 0xe0,
misc_device = 0xef, misc_device = 0xef,
}; };
printf(", class: "); usb_debug(", class: ");
switch (class) { switch (class) {
case audio_device: case audio_device:
printf("audio\n"); usb_debug("audio\n");
break; break;
case comm_device: case comm_device:
printf("communication\n"); usb_debug("communication\n");
break; break;
case hid_device: case hid_device:
printf ("HID\n"); usb_debug ("HID\n");
#ifdef CONFIG_USB_HID #ifdef CONFIG_USB_HID
controller->devices[adr]->init = usb_hid_init; controller->devices[adr]->init = usb_hid_init;
#else #else
@ -407,16 +407,16 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
#endif #endif
break; break;
case physical_device: case physical_device:
printf("physical\n"); usb_debug("physical\n");
break; break;
case imaging_device: case imaging_device:
printf("camera\n"); usb_debug("camera\n");
break; break;
case printer_device: case printer_device:
printf("printer\n"); usb_debug("printer\n");
break; break;
case msc_device: case msc_device:
printf ("MSC\n"); usb_debug ("MSC\n");
#ifdef CONFIG_USB_MSC #ifdef CONFIG_USB_MSC
controller->devices[adr]->init = usb_msc_init; controller->devices[adr]->init = usb_msc_init;
#else #else
@ -424,7 +424,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
#endif #endif
break; break;
case hub_device: case hub_device:
printf ("hub\n"); usb_debug ("hub\n");
#ifdef CONFIG_USB_HUB #ifdef CONFIG_USB_HUB
controller->devices[adr]->init = usb_hub_init; controller->devices[adr]->init = usb_hub_init;
#else #else
@ -432,28 +432,28 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
#endif #endif
break; break;
case cdc_device: case cdc_device:
printf("CDC\n"); usb_debug("CDC\n");
break; break;
case ccid_device: case ccid_device:
printf("smartcard / CCID\n"); usb_debug("smartcard / CCID\n");
break; break;
case security_device: case security_device:
printf("content security\n"); usb_debug("content security\n");
break; break;
case video_device: case video_device:
printf("video\n"); usb_debug("video\n");
break; break;
case healthcare_device: case healthcare_device:
printf("healthcare\n"); usb_debug("healthcare\n");
break; break;
case diagnostic_device: case diagnostic_device:
printf("diagnostic\n"); usb_debug("diagnostic\n");
break; break;
case wireless_device: case wireless_device:
printf("wireless\n"); usb_debug("wireless\n");
break; break;
default: default:
printf("unsupported class %x\n", class); usb_debug("unsupported class %x\n", class);
break; break;
} }
return adr; return adr;

View File

@ -407,11 +407,11 @@ static int usb_hid_set_layout (const char *country)
/* Found, changing keyboard layout */ /* Found, changing keyboard layout */
map = &keyboard_layouts[i]; map = &keyboard_layouts[i];
printf(" Keyboard layout '%s'\n", map->country); usb_debug(" Keyboard layout '%s'\n", map->country);
return 0; return 0;
} }
printf(" Keyboard layout '%s' not found, using '%s'\n", usb_debug(" Keyboard layout '%s' not found, using '%s'\n",
country, map->country); country, map->country);
/* Nothing found, not changed */ /* Nothing found, not changed */

View File

@ -67,47 +67,47 @@ static int usb_controller_initialize(int bus, int dev, int func)
pci_command |= PCI_COMMAND_MASTER; pci_command |= PCI_COMMAND_MASTER;
pci_write_config32(addr, PCI_COMMAND, pci_command); pci_write_config32(addr, PCI_COMMAND, pci_command);
printf("%02x:%02x.%x %04x:%04x.%d ", bus, dev, func, usb_debug("%02x:%02x.%x %04x:%04x.%d ", bus, dev, func,
pciid >> 16, pciid & 0xFFFF, func); pciid >> 16, pciid & 0xFFFF, func);
switch (prog_if) { switch (prog_if) {
case 0x00: case 0x00:
#ifdef CONFIG_USB_UHCI #ifdef CONFIG_USB_UHCI
printf("UHCI controller\n"); usb_debug("UHCI controller\n");
uhci_init (addr); uhci_init (addr);
#else #else
printf("UHCI controller (not supported)\n"); usb_debug("UHCI controller (not supported)\n");
#endif #endif
break; break;
case 0x10: case 0x10:
#ifdef CONFIG_USB_OHCI #ifdef CONFIG_USB_OHCI
printf("OHCI controller\n"); usb_debug("OHCI controller\n");
ohci_init(addr); ohci_init(addr);
#else #else
printf("OHCI controller (not supported)\n"); usb_debug("OHCI controller (not supported)\n");
#endif #endif
break; break;
case 0x20: case 0x20:
#ifdef CONFIG_USB_EHCI #ifdef CONFIG_USB_EHCI
printf("EHCI controller\n"); usb_debug("EHCI controller\n");
ehci_init(addr); ehci_init(addr);
#else #else
printf("EHCI controller (not supported)\n"); usb_debug("EHCI controller (not supported)\n");
#endif #endif
break; break;
case 0x30: case 0x30:
#ifdef CONFIG_USB_XHCI #ifdef CONFIG_USB_XHCI
printf("xHCI controller\n"); usb_debug("xHCI controller\n");
xhci_init(addr); xhci_init(addr);
#else #else
printf("xHCI controller (not supported)\n"); usb_debug("xHCI controller (not supported)\n");
#endif #endif
break; break;
default: default:
printf("unknown controller %x not supported\n", usb_debug("unknown controller %x not supported\n",
prog_if); prog_if);
break; break;
} }

View File

@ -143,7 +143,7 @@ reset_transport (usbdev_t *dev)
if (dev->controller->control (dev, OUT, sizeof (dr), &dr, 0, 0) || if (dev->controller->control (dev, OUT, sizeof (dr), &dr, 0, 0) ||
clear_stall (MSC_INST (dev)->bulk_in) || clear_stall (MSC_INST (dev)->bulk_in) ||
clear_stall (MSC_INST (dev)->bulk_out)) { clear_stall (MSC_INST (dev)->bulk_out)) {
printf ("Detaching unresponsive device.\n"); usb_debug ("Detaching unresponsive device.\n");
usb_detach_device (dev->controller, dev->address); usb_detach_device (dev->controller, dev->address);
return MSC_COMMAND_DETACHED; return MSC_COMMAND_DETACHED;
} }
@ -394,14 +394,14 @@ read_capacity (usbdev_t *dev)
} }
if (count >= 20) { if (count >= 20) {
// still not successful, assume 2tb in 512byte sectors, which is just the same garbage as any other number, but probably more usable. // still not successful, assume 2tb in 512byte sectors, which is just the same garbage as any other number, but probably more usable.
printf (" assuming 2 TB with 512-byte sectors as READ CAPACITY didn't answer.\n"); usb_debug (" assuming 2 TB with 512-byte sectors as READ CAPACITY didn't answer.\n");
MSC_INST (dev)->numblocks = 0xffffffff; MSC_INST (dev)->numblocks = 0xffffffff;
MSC_INST (dev)->blocksize = 512; MSC_INST (dev)->blocksize = 512;
} else { } else {
MSC_INST (dev)->numblocks = ntohl (*(u32 *) buf) + 1; MSC_INST (dev)->numblocks = ntohl (*(u32 *) buf) + 1;
MSC_INST (dev)->blocksize = ntohl (*(u32 *) (buf + 4)); MSC_INST (dev)->blocksize = ntohl (*(u32 *) (buf + 4));
} }
printf (" %d %d-byte sectors (%d MB)\n", MSC_INST (dev)->numblocks, usb_debug (" %d %d-byte sectors (%d MB)\n", MSC_INST (dev)->numblocks,
MSC_INST (dev)->blocksize, MSC_INST (dev)->blocksize,
/* round down high block counts to avoid integer overflow */ /* round down high block counts to avoid integer overflow */
MSC_INST (dev)->numblocks > 1000000 MSC_INST (dev)->numblocks > 1000000
@ -433,7 +433,7 @@ usb_msc_init (usbdev_t *dev)
if (interface->bInterfaceProtocol != 0x50) { if (interface->bInterfaceProtocol != 0x50) {
printf (" Protocol not supported.\n"); usb_debug (" Protocol not supported.\n");
return; return;
} }
@ -441,7 +441,7 @@ usb_msc_init (usbdev_t *dev)
(interface->bInterfaceSubClass != 5) && // ATAPI 8070 (interface->bInterfaceSubClass != 5) && // ATAPI 8070
(interface->bInterfaceSubClass != 6)) { // SCSI (interface->bInterfaceSubClass != 6)) { // SCSI
/* Other protocols, such as ATAPI don't seem to be very popular. looks like ATAPI would be really easy to add, if necessary. */ /* Other protocols, such as ATAPI don't seem to be very popular. looks like ATAPI would be really easy to add, if necessary. */
printf (" Interface SubClass not supported.\n"); usb_debug (" Interface SubClass not supported.\n");
return; return;
} }
@ -468,11 +468,11 @@ usb_msc_init (usbdev_t *dev)
} }
if (MSC_INST (dev)->bulk_in == 0) { if (MSC_INST (dev)->bulk_in == 0) {
printf("couldn't find bulk-in endpoint"); usb_debug("couldn't find bulk-in endpoint");
return; return;
} }
if (MSC_INST (dev)->bulk_out == 0) { if (MSC_INST (dev)->bulk_out == 0) {
printf("couldn't find bulk-out endpoint"); usb_debug("couldn't find bulk-out endpoint");
return; return;
} }
usb_debug (" using endpoint %x as in, %x as out\n", usb_debug (" using endpoint %x as in, %x as out\n",
@ -481,7 +481,7 @@ usb_msc_init (usbdev_t *dev)
usb_debug (" has %d luns\n", get_max_luns (dev) + 1); usb_debug (" has %d luns\n", get_max_luns (dev) + 1);
printf (" Waiting for device to become ready..."); usb_debug (" Waiting for device to become ready...");
timeout = 30 * 10; /* SCSI/ATA specs say we have to wait up to 30s. Ugh */ timeout = 30 * 10; /* SCSI/ATA specs say we have to wait up to 30s. Ugh */
while (timeout--) { while (timeout--) {
switch (test_unit_ready (dev)) { switch (test_unit_ready (dev)) {
@ -490,7 +490,7 @@ usb_msc_init (usbdev_t *dev)
case MSC_COMMAND_FAIL: case MSC_COMMAND_FAIL:
mdelay (100); mdelay (100);
if (!(timeout % 10)) if (!(timeout % 10))
printf ("."); usb_debug (".");
continue; continue;
default: /* if it's worse return */ default: /* if it's worse return */
return; return;
@ -498,9 +498,9 @@ usb_msc_init (usbdev_t *dev)
break; break;
} }
if (timeout < 0) { if (timeout < 0) {
printf ("timeout. Device not ready. Still trying...\n"); usb_debug ("timeout. Device not ready. Still trying...\n");
} else { } else {
printf ("ok.\n"); usb_debug ("ok.\n");
} }
usb_debug (" spin up"); usb_debug (" spin up");

View File

@ -120,9 +120,9 @@ xhci_init (pcidev_t addr)
XHCI_INST (controller)->opreg->dcbaap_lo = virt_to_phys(XHCI_INST (controller)->dcbaa); XHCI_INST (controller)->opreg->dcbaap_lo = virt_to_phys(XHCI_INST (controller)->dcbaa);
XHCI_INST (controller)->opreg->dcbaap_hi = 0; XHCI_INST (controller)->opreg->dcbaap_hi = 0;
printf("waiting for controller to be ready - "); usb_debug("waiting for controller to be ready - ");
while ((XHCI_INST (controller)->opreg->usbsts & USBSTS_CNR) != 0) mdelay(1); while ((XHCI_INST (controller)->opreg->usbsts & USBSTS_CNR) != 0) mdelay(1);
printf("ok.\n"); usb_debug("ok.\n");
usb_debug("ERST Max: %lx -> %lx entries\n", XHCI_INST (controller)->capreg->ERST_Max, 1<<(XHCI_INST (controller)->capreg->ERST_Max)); usb_debug("ERST Max: %lx -> %lx entries\n", XHCI_INST (controller)->capreg->ERST_Max, 1<<(XHCI_INST (controller)->capreg->ERST_Max));