Your references are good but lack a definition of what is a platform device. There is one on LWN. What we can learn from this page:
Platform devices are inherently not discoverable, i.e. the hardware cannot say "Hey! I'm present!" to the software. Typical examples are i2c devices, kernel/Documentation/i2c/instantiating-devices
states:
Unlike PCI or USB devices, I2C devices are not enumerated at the hardware level (at run time).
Instead, the software must know (at compile time) which devices are connected on each I2C bus segment.
So USB and PCI are not platform devices.
Platform devices are bound to drivers by matching names,
- Platform devices should be registered very early during system boot. Because they are often critical to the rest of the system (platform) and its drivers.
So basically, the question "is it a platform device or a standard device?" is more a question of which bus it uses. To work with a particular platform device, you have to:
- register a platform driver that will manage this device. It should define a unique name,
- register your platform device, defining the same name as the driver.
Platform driver is for those devices that are on chip.
Not true (in theory, but true in practice). i2c devices are not onChip, but are platform devices because they are not discoverable. Also we can think of onChip devices which are normal devices. Example: an integrated PCI GPU chip on a modern x86 processor. It is discoverable, thus not a platform device.
Normal device driver are for those that are interfaced to the processor chip. before coming across one i2c driver.
Not true. Many normal devices are interfaced to the processor, but not through an i2c bus. Example: a USB mouse.
[EDIT] In your case, have a look to drivers/usb/host/ohci-pnx4008.c
, which is a USB host controller platform device (Here the USB host controller is not discoverable, whereas USB devices, which will connect to it, are). It is a platform device registered by the board file (arch/arm/mach-pnx4008/core.c:pnx4008_init
). And within its probe function, it registers its i2c device to the bus with i2c_register_driver
. We can infer that the USB Host controller chipset talks to the CPU through an i2c bus.
Why that architecture? Because on one hand, this device can be considered a bare i2c device providing some functionalities to the system. On the other hand, it is a USB Host capable device. It needs to register to the USB stack (usb_create_hcd
). So probing only i2c will be insufficient. Have a look to Documentation/i2c/instantiating-devices
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…