Reputation: 3544
I'd like to know, which part of the system is responsible for detection of plugged-in device in the USB port
It may be a USB host port, so that a plugged-in device will be considered a USB client (so port owner is host),
or it may be a USB client port, so that a plugged-in device will be considered a USB host (so port owner is client)
What I am interested in is a moment WHEN the system actually detects (by change of resistance maybe) that something has been plugged in, and based on from which port the signal is coming (host port or client port), either host port driver or client port driver is deployed
I want to know, HOW system picks up this or that driver, based on that "plugged-in" event
Where should I look for that ? In USB core maybe ?
Upvotes: 5
Views: 8327
Reputation: 3949
The usb subsystem is responsible for detecting and probing newly added/hotplugged USB devices. Look in the kernel logs for messages like:
usb usb4: New USB device found, idVendor=1d6b, idProduct=0001
usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb4: Product: OHCI Host Controller
usb usb4: Manufacturer: Linux 2.6.32 ohci_hcd
usb usb4: SerialNumber: 0000:00:12.1
usb usb4: configuration #1 chosen from 1 choice
The code which handles all this is located in drivers/usb/core
The usb subsystem sits below the scsi subsystem and hence your newly allocated devices will have device names like /dev/sdX
. Its the job of udev to create a new device node corresponding to this USB device in /dev
. If you are interested in capturing this event and running a script that does some notifications you may wanna read up on how to edit udevd rules: http://www.reactivated.net/writing_udev_rules.html#external-run
Upvotes: 1
Reputation: 991
Hi when android device is connected then it is in client mode (atleast in samsung devices it is) and when the device is connected then at first the address of the device is set to 0x0 so that the default address is known by the host. Then there is endpoint 0 through which all the setup is done (configuration, interface, endpoints).
The above image will help you to understand. This is taken from USB 2.0 manual. Remember that all the setting during initialization are done through endpoint 0 which is present in every device.
And i dont know how to change it from client to host mode. (My knowledge is limited to that there is negotiation done after setup in OTG mode). I hope i helped.
Upvotes: 1
Reputation: 991
I understand what you are asking, and rightly when a usb device is connected then the current fluctuation (across resistors) leads to notification. Then the host (there can be negotiation that who will be host in OTG mode but that also happens after enumeration process).
Enumeration is main process which is most important. USB follows star tier topology and whole system is based on same.
NOTE: It is very important to note that all the transactions of packets are initiated by host. The client is at mercy of host. This is very important in understanding the usb system.
Pls refer: http://www.beyondlogic.org/usbnutshell/usb1.shtml
Upvotes: 1