mini2440 usb host device controller驱动分析(四)-----root hub驱动的分析(二)

本文深入探讨USB Root Hub如何感应并枚举新插入的设备,包括获取描述符、设置地址等关键步骤。枚举过程中,root hub负责初始化并与设备交互,而后续操作由class driver接管。枚举过程中涉及设备UDC的地址设置,并在连接变化时调用hub_port_init,通过重试机制确保枚举成功。同时,文章提及每个endpoint也有独立地址,但其具体用途未详述。
摘要由CSDN通过智能技术生成

接下来开始讲设备的枚举过程。

前面分析了root hub感应设备插拔的过程。root hub还有一个功能是对新插入的设备进行枚举。其实root hub完成了枚举的前几个步骤:get descriptor  、 set address 、 get configuration。 枚举的后面几个步骤是由上层的class driver来完成的,这个后面在分析。

在前面的hub_port_connect_change中调用了hub_port_init中,我们可以看到这个枚举的过程。 

static int
hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
		int retry_counter)
{
	static DEFINE_MUTEX(usb_address0_mutex);

	struct usb_device	*hdev = hub->hdev;
	struct usb_hcd		*hcd = bus_to_hcd(hdev->bus);
	int			i, j, retval;
	unsigned		delay = HUB_SHORT_RESET_TIME;
	enum usb_device_speed	oldspeed = udev->speed;
	char 			*speed, *type;
	int			devnum = udev->devnum;

	/* root hub ports have a slightly longer reset period
	 * (from USB 2.0 spec, section 7.1.7.5)
	 */
	if (!hdev->parent) {
		delay = HUB_ROOT_RESET_TIME;
		if (port1 == hdev->bus->otg_port)
			hdev->bus->b_hnp_enable = 0;
	}

	/* Some low speed devices have problems with the quick delay, so */
	/*  be a bit pessimistic with those devices. RHbug #23670 */
	if (oldspeed == USB_SPEED_LOW)
		delay = HUB_LONG_RESET_TIME;

	mutex_lock(&usb_address0_mutex);


	/* Reset the device; full speed may morph to high speed */
		/* FIXME a USB 2.0 device may morph into SuperSpeed on reset. */
		retval = hub_port_reset(hub, port1, udev, delay);
		if (retval < 0)		/* error or disconnect */
			goto fail;
		/* success, speed is known */
	
	retval = -ENODEV;

	if (oldspeed != USB_SPEED_UNKNOWN && oldspeed != udev->speed) {
		dev_dbg(&udev->dev, "device reset changed speed!\n");
		goto fail;
	}
	oldspeed = udev->speed;
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值