Usb Hub代码分析
如需引用请注明出处:http://blog.csdn.net/zkami 作者:ZhengKui
在host controller初始化的时候一定会调用hub_probe进行初始化,至少对root hub初始化
hub_probe(struct usb_interface *intf, const struct usb_device_id *id) (hub.c)
此时struct usb_interface 和struct usb_device的数据已经在hc初始化的过程中得到
-> hdev = interface_to_usbdev(intf);
由struct usb_interface 得到usb_device, 中间通过struct device转换,
然后:分配struct usb_hub, 并初始化hub->event_list和hub->leds
-> INIT_DELAYED_WORK(&hub->leds, led_work);初始化led_work工作队列
以后调用schedule_delayed_work()来唤醒led_work, 暂时不用led
-> usb_get_intf(intf);
-> usb_set_intfdata (intf, hub);让struct usb_hub和struct usb_interface关联
-> hub_configure(hub, endpoint)
->get_hub_descriptor(hdev, hub->descriptor,sizeof(*hub->descriptor));
得到hub->descriptor
-> usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0),
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB,
USB_DT_HUB << 8, 0, data, size,
USB_CTRL_GET_TIMEOUT);
对tt初始化, struct usb_tt用来匹配低速设备和高速hub.tt与hub相关与OHCI/EHCI无关
这样一个port既能支持high也能支持full/low
-> INIT_WORK (&hub->tt.kevent, hub_tt_kevent);
-> hub_tt_kevent()
-> usb_set_interface(hdev, 0, 1); high speed hub
-> usb_get_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus);
-> usb_control_msg(dev, usb_rcvctrlpip
如需引用请注明出处:http://blog.csdn.net/zkami 作者:ZhengKui
在host controller初始化的时候一定会调用hub_probe进行初始化,至少对root hub初始化
hub_probe(struct usb_interface *intf, const struct usb_device_id *id) (hub.c)
此时struct usb_interface 和struct usb_device的数据已经在hc初始化的过程中得到
-> hdev = interface_to_usbdev(intf);
由struct usb_interface 得到usb_device, 中间通过struct device转换,
然后:分配struct usb_hub, 并初始化hub->event_list和hub->leds
-> INIT_DELAYED_WORK(&hub->leds, led_work);初始化led_work工作队列
以后调用schedule_delayed_work()来唤醒led_work, 暂时不用led
-> usb_get_intf(intf);
-> usb_set_intfdata (intf, hub);让struct usb_hub和struct usb_interface关联
-> hub_configure(hub, endpoint)
->get_hub_descriptor(hdev, hub->descriptor,sizeof(*hub->descriptor));
得到hub->descriptor
-> usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0),
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB,
USB_DT_HUB << 8, 0, data, size,
USB_CTRL_GET_TIMEOUT);
对tt初始化, struct usb_tt用来匹配低速设备和高速hub.tt与hub相关与OHCI/EHCI无关
这样一个port既能支持high也能支持full/low
-> INIT_WORK (&hub->tt.kevent, hub_tt_kevent);
-> hub_tt_kevent()
-> usb_set_interface(hdev, 0, 1); high speed hub
-> usb_get_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus);
-> usb_control_msg(dev, usb_rcvctrlpip