示例#1
0
int usb_init(void)
{
	int result;

	running = 0;
	dev_index = 0;
	asynch_allowed = 1;
	usb_hub_reset();
	/* init low_level USB */
	printf("USB:   ");
	result = usb_lowlevel_init();
	/* if lowlevel init is OK, scan the bus for devices
	 * i.e. search HUBs and configure them */
	if (result == 0) {
		printf("scanning bus for devices... ");
		running = 1;
		usb_scan_devices();
		usb_started = 1;
		return 0;
	} else {
		printf("Error, couldn't init Lowlevel part\n");
		usb_started = 0;
		return -1;
	}
}
示例#2
0
文件: usb.c 项目: RAR/apc-8750
int usb_init(void)
{
	int result;
	running = 0;
	dev_index = 0;
	asynch_allowed = 1;
	usb_hub_reset();
	/* init low_level USB */
	result = usb_lowlevel_init();
 	/* if lowlevel init is OK, scan the bus for devices i.e. search HUBs and configure them */
	if(result == 0) {
		printf("scanning bus for devices...\n ");
		running = 1;
		/*empty port not scan*/
		/*printf("port_connect_status:%x,usb_sel:%x\n",port_connect_status,usb_sel);*/
		if (port_connect_status != usb_sel) {
			printf("Error, couldn't init Lowlevel part\n");
			return -1;
		}
		result = usb_scan_devices();
		if (result < 0 )
			return -1;
		else 
			return 0;
	} else {
		printf("Error, couldn't init Lowlevel part\n");
		return -1;
	}
}
示例#3
0
文件: usb.c 项目: jait/witi-uboot
int usb_init(void)
{
	int result;
	void *ctrl;
	int i, start_index = 0;
        struct usb_device *dev;

	gpio_init_usb(1);

	running=0;
	dev_index=0;
	asynch_allowed=1;
	usb_hub_reset();

        /* first make all devices unknown */
        for (i = 0; i < USB_MAX_DEVICE; i++) {
                memset(&usb_dev[i], 0, sizeof(struct usb_device));
                usb_dev[i].devnum = -1;
        }

        /* init low_level USB */
#define	CONFIG_USB_MAX_CONTROLLER_COUNT 1
        for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
                /* init low_level USB */
                printf("USB%d:   ", i);
                if (usb_lowlevel_init(i, USB_INIT_HOST, &ctrl)) {
                        puts("lowlevel init failed\n");
                        continue;
                }
                /*
                 * lowlevel init is OK, now scan the bus for devices
                 * i.e. search HUBs and configure them
                 */
                start_index = dev_index;
                printf("scanning bus %d for devices... ", i);
                dev = usb_alloc_new_device(ctrl);
                /*
                 * device 0 is always present
                 * (root hub, so let it analyze)
                 */
                if (dev)
                        usb_new_device(dev);

                if (start_index == dev_index)
                        puts("No USB Device found\n");
                else
                        printf("%d USB Device(s) found\n",
                                dev_index - start_index);

		running = 1;
        }

        USB_PRINTF("scan end\n");
        if (!running) {
                puts("USB error: all controllers failed lowlevel init\n");
                return -1;
        }

	return 0;
}
示例#4
0
文件: usb.c 项目: disdi/u-boot-cavium
/***************************************************************************
 * Init USB Device
 */
int usb_init(void)
{
	void *ctrl;
	struct usb_device *dev;
	int i, start_index = 0;

	dev_index = 0;
	asynch_allowed = 1;
	usb_hub_reset();

	/* first make all devices unknown */
	for (i = 0; i < USB_MAX_DEVICE; i++) {
		memset(&usb_dev[i], 0, sizeof(struct usb_device));
		usb_dev[i].devnum = -1;
	}

	/* init low_level USB */
	for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
		/* init low_level USB */
		printf("USB%d:   ", i);
		if (usb_lowlevel_init(i, USB_INIT_HOST, &ctrl)) {
#if defined(CONFIG_OCTEON) && defined(CONFIG_OCTEON_OCX)
			if (i == 0)
#endif
				puts("lowlevel init failed\n");
			continue;
		}
		usb_controller_initialized[i] = true;
		/*
		 * lowlevel init is OK, now scan the bus for devices
		 * i.e. search HUBs and configure them
		 */
		start_index = dev_index;
		printf("scanning bus %d for devices... ", i);
		dev = usb_alloc_new_device(ctrl);
		/*
		 * device 0 is always present
		 * (root hub, so let it analyze)
		 */
		if (dev)
			usb_new_device(dev);

		if (start_index == dev_index)
			puts("No USB Device found\n");
		else
			printf("%d USB Device(s) found\n",
				dev_index - start_index);

		usb_started = 1;
	}

	debug("scan end\n");
	/* if we were not able to find at least one working bus, bail out */
	if (!usb_started) {
		puts("USB error: all controllers failed lowlevel init\n");
		return -1;
	}

	return 0;
}
示例#5
0
int _usb_init(int port)
{
    int result=0;

#if 0
    //#if defined (CONFIG_TITANIA8) || defined(CONFIG_JANUS2)
    // Force USB to use MIU0.
    *((unsigned char volatile *)(0xBF200000+0x600*2+0xF0*2+1)) =  (*((unsigned char volatile *)(0xBF200000+0x600*2+0xF0*2+1))
              & 0xF1) ;
    *((unsigned char volatile *)(0xBF200000+0x1200*2+0xF0*2+1)) =  (*((unsigned char volatile *)(0xBF200000+0x1200*2+0xF0*2+1))
              & 0xF1) ;
#endif

    if ((port==0)||(port==1)||(port==2))
        UsbPortSelect=port;
    else
        UsbPortSelect=0;

    //running=0;
    dev_index=0;
    asynch_allowed=1;
    printf("Check USB port[%d]:\n", port);
    usb_hub_reset();
    /* init low_level USB */
    //retry:
    result = usb_lowlevel_init();
    /* if lowlevel init is OK, scan the bus for devices i.e. search HUBs and configure them */
    if(result==0) {
        printf("scanning bus for devices... ");
        //running=1;
        result=usb_scan_devices();
        if(result) {
            printf("Error, bad or unsupported device...\n");
            usb_started = 0;
            return -1;
        }
        usb_started = 1;
#if (CONFIG_COMMANDS & CFG_CMD_FAT)
        {
            char cmd_buf[32];
            extern int snprintf(char *str, size_t size, const char *fmt, ...);
            memset(cmd_buf, 0 , sizeof(cmd_buf));
            snprintf(cmd_buf, sizeof(cmd_buf), "setenv %s", ENV_PARTNO);
            run_command(cmd_buf, 0);
        }
#endif
        return 0;
    }
    else {
        printf("Error, couldn't init Lowlevel part\n");
        usb_started = 0;
        return -1;
    }
}
示例#6
0
/*--- Dispatcher ---*/
int32 USBHost::dispatch(uint32 fncode)
{
	int32 ret;

	D(bug("USBHost: dispatch(%u)", fncode));
	ret = EINVFN;

	switch(fncode) {
		case GET_VERSION:
			D(bug("USBHost: getVersion"));
			ret = USBHOST_NFAPI_VERSION;
			break;

		case USBHOST_INTLEVEL:
			D(bug("USBHost: getINTlevel"));
			ret = INTLEVEL;
			break;

		case USBHOST_RH_PORT_STATUS:
			ret = rh_port_status(getParameter(0));
			break;

		case USBHOST_LOWLEVEL_INIT:
			ret = usb_lowlevel_init();
			break;

		case USBHOST_LOWLEVEL_STOP:
			ret = usb_lowlevel_stop();
			break;

		case USBHOST_SUBMIT_CONTROL_MSG:
			ret = submit_control_msg(getParameter(0), getParameter(1), getParameter(2),
						getParameter(3));
			break;

		case USBHOST_SUBMIT_INT_MSG:
			ret = submit_int_msg(getParameter(0), getParameter(1), getParameter(2),
						getParameter(3));
			break;

		case USBHOST_SUBMIT_BULK_MSG:
			ret = submit_bulk_msg(getParameter(0), getParameter(1), getParameter(2));
			break;
		default:
			D(bug("USBHost: unimplemented function #%d", fncode));
			break;
	}

	D(bug("USBHost: function returning with 0x%08x", ret));

	return ret;
}
示例#7
0
文件: usb.c 项目: XProjectHg/uboot
/***************************************************************************
 * Init USB Device
 */
int usb_init(void)
{
	void *ctrl;
	struct usb_device *dev;
	int i, start_index = 0;
	int controllers_initialized = 0;
	int ret;

	dev_index = 0;
	asynch_allowed = 1;
	usb_hub_reset();

	/* first make all devices unknown */
	for (i = 0; i < USB_MAX_DEVICE; i++) {
		memset(&usb_dev[i], 0, sizeof(struct usb_device));
		usb_dev[i].devnum = -1;
	}

	/* init low_level USB */
	for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
		/* init low_level USB */
		printf("USB%d:   ", i);
		ret = usb_lowlevel_init(i, USB_INIT_HOST, &ctrl);
		if (ret == -ENODEV) {	/* No such device. */
			puts("Port not available.\n");
			controllers_initialized++;
			continue;
		}

		if (ret) {		/* Other error. */
			puts("lowlevel init failed\n");
			continue;
		}
		/*
		 * lowlevel init is OK, now scan the bus for devices
		 * i.e. search HUBs and configure them
		 */
		controllers_initialized++;
		start_index = dev_index;
		printf("scanning bus %d for devices... ", i);
		ret = usb_alloc_new_device(ctrl, &dev);
		if (ret)
			break;

		/*
		 * device 0 is always present
		 * (root hub, so let it analyze)
		 */
		ret = usb_new_device(dev);
		if (ret)
			usb_free_device(dev->controller);

		if (start_index == dev_index) {
			puts("No USB Device found\n");
			continue;
		} else {
			printf("%d USB Device(s) found\n",
				dev_index - start_index);
		}

		usb_started = 1;
	}

	debug("scan end\n");
	/* if we were not able to find at least one working bus, bail out */
	if (controllers_initialized == 0)
		puts("USB error: all controllers failed lowlevel init\n");

	return usb_started ? 0 : -ENODEV;
}