Ejemplo n.º 1
0
s32 USBStorage_Init(void)
{
        int i;
        //debug_printf("usbstorage init %d\n", ums_init_done);
        if(ums_init_done)
          return 0;
        ums_init_done = 1;
        for(i = 0;i<ehci->num_port; i++){
                struct ehci_device *dev = &ehci->devices[i];
                if(dev->id != 0){
                        USBStorage_Try_Device(dev);
                }
        }
        return 0;
}
Ejemplo n.º 2
0
int unplug_procedure(int device) {
	int retval = 1;
	if (unplug_device != 0) {

		if (_ehci_data[device].__usbfd.usb_fd)
			if (ehci_reset_port2(_ehci_data[device].__ehci, /*__usbfd.usb_fd->port*/0) >= 0) {
				if (_ehci_data[device].__usbfd.buffer != NULL)
					USB_Free(_ehci_data[device].__usbfd.buffer);
				_ehci_data[device].__usbfd.buffer = NULL;

				if (ehci_reset_port(_ehci_data[device].__ehci, 0) >= 0) {
					handshake_mode = 1;
					if (USBStorage_Try_Device(&_ehci_data[device]) == 0) {
						retval = 0;
						unplug_device = 0;
					}
					handshake_mode = 0;
				}
			}
		ehci_msleep(100);
	}

	return retval;
}
Ejemplo n.º 3
0
s32 USBStorage_Init(void) {
	int i, j, retries = 1;
	//	debug_printf("usbstorage init %d\n", ums_init_done);
	if (!ums_init_done)
	{
		_ehci_device_count = 0;
		init_ehci_device_struct();
	}
	struct ehci_hcd *ehci = &ehci_hcds[0];

	try_status = -1;

	for (j = 0; j < EHCI_HCD_COUNT; j++) {

		for (i = 0; i < ehci->num_port; i++) {
			struct ehci_device *dev = &ehci->devices[i];

retry:
			dev->port = i;
			if (dev->id != 0 && dev->busy == 0) {
				handshake_mode = 1;
				if (ehci_reset_port(ehci, i) >= 0) {

					//ehci_device_data * device_data = find_ehci_data(ehci);
					
					ehci_device_data * device_data = &_ehci_data[_ehci_device_count];
					dev->busy = 1;
					device_data->__ehci = ehci;
					device_data->__dev = dev;					

					if (USBStorage_Try_Device(device_data) == 0) {
						printf("EHCI bus %d device %d: vendor %04X product %04X : Mass-Storage Device\n", j, dev->id, device_data->__vid, device_data->__pid);

						first_access = TRUE;
						handshake_mode = 0;
						ums_init_done = 1;
						unplug_device = 0;
						//__bdev=register_bdev(NULL, &usb2mass_ops, "uda");
						//register_disc_interface(&usb2mass_ops);
						device_data->__ready = 1;
						if (mount_usb_device)						
							mount_usb_device(_ehci_device_count);						
						_ehci_device_count++;
#ifdef MEM_PRINT
						s_printf("USBStorage_Init() Ok\n");

#endif

						//return 0;
					}
				}
			} else if (dev->busy == 0) {
				u32 status;
				handshake_mode = 1;
				status = ehci_readl(&ehci->regs->port_status[i]);

#ifdef MEM_PRINT
				s_printf("USBStorage_Init() status %x\n", status);

#endif

				if (status & 1) {
					if (ehci_reset_port2(ehci, i) < 0) {
						ehci_msleep(100);
						ehci_reset_port(ehci, i);
					}
					if (retries) {
						retries--;
						goto retry;
					}
				}
			}
		}

		ehci++;
	}

	return try_status;
}