Hi Turwei,
The first session, to find driver "usb":
there's some diagram being drawn, but it doesn’t render nicely in text… so we can’t be sure where the figure ended and where narration continues. Similarly with
The misson of the second session is to find driver "skeleton"
I was going to ask about how Linux arrives at the 'device 1-1:1.0’ but I see later that this gets populated with the lines
dev_set_name(&intf->dev, "%d-%s:%d.%d", /** "1-1:1.0" */
dev->bus->busnum, dev->devpath,
configuration, alt->desc.bInterfaceNumber);
[HONGAO]: This part is missing, will update it as following:
for driver "usb", __device_attach will firstly call driver_match_device->usb_device_match->is_usb_device->is_usb_device_driver. "usb" is surely belongs to usb device driver so it returns TRUE, so after that driver_probe_device(drv, dev) is called. And eventually kernel calls usb_set_configuration so Linux arrives at the 'device 1-1:1.0’.
to find driver "skeleton", __device_attach will firstly call driver_match_device->usb_device_match->is_usb_interface->usb_match_id(intf, usb_drv->id_table); which is to compare some parameters like vendor ID, product ID, etc, to see if the driver match the attached device or not. If you read in lines, you can find out the skeleton id_table is:
/* table of devices that work with this driver */
static const struct usb_device_id skel_table[] = {
{ USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) },
{ USB_DEVICE(0x0781, 0x5151)}, /** hongao: this is to support Sandisk USB thumb-drive */
{ } /* Terminating entry */
};
I added USB_DEVICE(0x0781, 0x5151) to let my driver matches my sandisk device. So at driver "skeletion", usb_device_match returns TRUE, thus driver_probe_device(drv, dev) get called.
Do you know how composite USB devices get attached to the system?
[HONGAO]: for composite USB devices you have to know the device information such as configurations, interfaces and endpoints of each interfaces firstly.
my sandisk usb thumb-drive is: 1-1:1.0, which means it is plugged-in root hub 1, hub port 1, configuration 1 and interface 0.
composite USB devices may have few configurations and interfaces, so kernel will get these information via usb CONTROL message and then call
usb_set_configuration to setup each of them. But actually i don't have a composite USB devices so far, so you can give me one and i try with my computer.
In the TV550 platform, the apps can query for USB device info through the /sys path, e.g.
/sys/devices/platform/pnx8xxx-usb-ip9028/usb1/1-1/1-1.2/1-1.2:1.0
Is it the same on our MTK platform? Is it equivalent on the Linux desktop?
[HONGAO]:for MTK platform i never tried. i tried on my Linux desktop. on my desktop, the USB device info is under:
/sys/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0
and from my document, i printed the information when the device is attached:
dev->bus->name="usb"
dev->parent->kobj->name="usb1"
dev->parent->bus->name="usb"
dev->parent->type->name="usb_device"
dev->parent->parent->kobj->name="0000:02:03.0"
dev->parent->parent->bus->name="pci"
dev->parent->parent->parent->kobj->name="0000:00:11.0"
dev->parent->parent->parent->bus->name="pci"
dev->parent->parent->parent->parent->kobj->name="pci0000:00"
dev->kobj->name="1-1"
dev->type->name="usb_device"
See, this is the same hiberarchy as what is shown in sysfs.
And as our embedded linux platforms don't have PCI, so the usb hub may be attached to some other buses.
I would like to study details of pnx8xxx-usb-ip9028 with you.
It will also be interesting if you can explain how this is implemented.
[HONGAO]:for new Linux kernels, SYSFS filesystem is implemented to replace the old PROC filesystem.
with SYSFS, all the device and driver informations are stored under /sys. I have not finish the documents
about SYSFS analysis. Once finished will update my blog.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hi,
Looks like from the line
The first session, to find driver "usb":
there's some diagram being drawn, but it doesn’t render nicely in text… so we can’t be sure where the figure ended and where narration continues. Similarly with
The misson of the second session is to find driver "skeleton"
I was going to ask about how Linux arrives at the 'device 1-1:1.0’ but I see later that this gets populated with the lines
dev_set_name(&intf->dev, "%d-%s:%d.%d", /** "1-1:1.0" */
dev->bus->busnum, dev->devpath,
configuration, alt->desc.bInterfaceNumber);
Do you know how composite USB devices get attached to the system?
In the TV550 platform, the apps can query for USB device info through the /sys path, e.g.
/sys/devices/platform/pnx8xxx-usb-ip9028/usb1/1-1/1-1.2/1-1.2:1.0
Is it the same on our MTK platform? Is it equivalent on the Linux desktop? It will also be interesting if you can explain how this is implemented.
Nice work, I look forward to reading more.
Regards
-T.W.Chan-