app:
-------------------------------------------
USB设备驱动程序 // 知道数据含义
内核 --------------------------------------
USB总线驱动程序 // 1. 识别, 2. 找到匹配的设备驱动, 3. 提供USB读写函数 (它不知道数据含义)
-------------------------------------------
USB主机控制器
UHCI OHCI EHCI
硬件 -----------
USB设备
UHCI: intel, 低速(1.5Mbps)/全速(12Mbps)
OHCI: microsoft 低速/全速
EHCI: 高速(480Mbps)
USB总线驱动程序相当于USB主机控制器的驱动程序。
对于Linux USB主机驱动程序 可以分析
Freezer
Upon entering a suspended state the system will freeze all tasks. This is done by delivering pseudosignals. This affects kernel threads, too. To successfully freeze a kernel thread the thread has to check for the pseudo signal and enter the refrigerator. Code to do this looks like this:
do { hub_events();
wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list)); try_to_freeze(); } while (!signal_pending(current));
from drivers/usb/core/hub.c::hub_thread()
在内核目录下搜:
grep "USB device using" * -nR
drivers/usb/core/hub.c:2186: "%s %s speed %sUSB device using %s and address %d\n",
hub_irq //最终还是irq 中断得到USB设备来了。
kick_khubd
hub_thread
hub_events
hub_port_connect_change
udev = usb_alloc_dev(hdev, hdev->bus, port1);
dev->dev.bus = &usb_bus_type;
choose_address(udev); // 给新设备分配编号(地址)
hub_port_init // usb 1-1: new full speed USB device using s3c2410-ohci and address 3
hub_set_address // 把编号(地址)告诉USB设备