* for the core. usb_add_device expected that
* the device answers to address zero.
*/
-struct usb_device *usb_add_device()
+struct usb_device *usb_add_device(u8 lowspeed)
{
struct usb_device *dev = (struct usb_device *) malloc(sizeof(struct usb_device));
dev->conf = (struct usb_conf *) malloc(sizeof(struct usb_conf));
dev->address = 0;
- /* send at first time only 8 bytes */
- dev->bMaxPacketSize0 = 8;
+ dev->fullspeed = lowspeed ? 0 : 1;
+ /* send at first time only 8 bytes for lowspeed devices
+ * 64 bytes for fullspeed
+ */
+ dev->bMaxPacketSize0 = lowspeed ? 8 : 64;
dev->epSize[0] = 64;
dev->epSize[1] = 64;
/* print device info */
lsusb(dev);
+#if 0
/* select configuration */
ret = usb_set_configuration(dev, dev->conf->bConfigurationValue);
printf("=============\nusb_set_configuration(ret: %d) %d\n", ret, dev->conf->bConfigurationValue);
printf("=============\nusb_get_configuration: %d\n", usb_get_configuration(dev));
+#endif
#if 0
u8 buf[8];
printf("iProduct(0x%02X): \"%s\"\n", dev->iProduct, dev->iProduct ? usb_get_string_simple(dev, dev->iProduct) : "no String");
printf("iSerialNumber(0x%02X): \"%s\"\n", dev->iSerialNumber, dev->iSerialNumber ? usb_get_string_simple(dev, dev->iSerialNumber) : "no String");
printf("bNumConfigurations 0x%02X\n", dev->bNumConfigurations);
-
+
u8 c, i, e;
struct usb_conf *conf = dev->conf;
for(c=0; c <= dev->bNumConfigurations; c++) {
ed = ed->next;
} //endpoint
-
+
ifs = ifs->next;
} //interface
td->iso = 0;
td->state = USB_TRANSFER_DESCR_NONE;
td->maxp = irp->epsize;
+ td->fullspeed = irp->dev->fullspeed;
return td;
}
struct usb_transfer_descriptor {
u8 devaddress;
u8 endpoint;
+ u8 fullspeed;
// TODO: zusammenfassen!
u8 pid;
u8 usb_next_address();
-struct usb_device *usb_add_device();
+struct usb_device *usb_add_device(u8 lowspeed);
u8 usb_remove_device(struct usb_device *dev);
u8 usb_register_driver(struct usb_driver *driver);
void usb_probe_driver();
memset(edhead, 0, sizeof(struct endpoint_descriptor));
edhead->flags = LE(OHCI_ENDPOINT_GENERAL_FORMAT);
edhead->headp = edhead->tailp = edhead->nexted = LE(0);
- edhead->flags |= LE(OHCI_ENDPOINT_LOW_SPEED |
- OHCI_ENDPOINT_SET_DEVICE_ADDRESS(td->devaddress) |
+ if(td->fullspeed) {
+ edhead->flags |= LE(OHCI_ENDPOINT_FULL_SPEED);
+ } else {
+ edhead->flags |= LE(OHCI_ENDPOINT_LOW_SPEED);
+ }
+ edhead->flags |= LE(OHCI_ENDPOINT_SET_DEVICE_ADDRESS(td->devaddress) |
OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(td->endpoint) |
OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(td->maxp));
edhead->tdcount = 0;
printf("loop done\n");
#endif
- (void) usb_add_device();
+ /* returns usb_device struct */
+ (void) usb_add_device((read32(reg) & RH_PS_LSDA) >> 8);
}
}