Reputation: 41
As i am new to embedded field i am facing difficulties in understanding the clear difference between i2c device/driver and platform device/driver.
i have read this link:
What is the difference between Platform driver and normal device driver..?
which say platform devices/driver are use for not discoverable device like devices connected at i2c bus and Platform devices are bound to drivers by matching names.
I have gone through a board file, in which audio codec(non discoverable device) connected at i2c bus is registered using i2c API (i2c_register_board_info, omap_i2c_add_bus etc.), so my questions are
Upvotes: 3
Views: 3089
Reputation: 1
- What is difference between i2c device/driver and platform device/driver ?
i2c device driver API is used to control the i2c peripheral from the i2c client driver like audio-codec
platform device driver API are used by non-discoverable devices say audio-codec to get the hardware related configuration via device tree or board file
Upvotes: 0
Reputation: 103
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-devicesstates: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.
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:
Are platform drivers 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.
Are normal device drivers 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.
Upvotes: 1
Reputation: 106
Every SOC(Silicon on Chip) or microcontroller will have a I2C controller, which provides a way to connect and communicate to I2C devices like camera sensors, PMIC, temperature sensor etc. The driver used for configuring and using this I2C controller is called platform driver. This I2C controller is called platform device. Mostly platform devices will be part of the SOC. The registers of the I2C controller are programmed using platform driver. These registers are in say ARM memory mapped and will be available on TRM of the SOC.
Now all the I2C devices that can be connected to the SOC or microcontroller via I2C controller like Camera sensors, PMIC, temperature sensor etc need a driver to control them. This driver is called device driver. The registers of these devices are not part of memory map of SOC. Need the datasheet of the I2C device like OV5640 Camera Sensor to program the registers. I2C data are sent out to program the registers and access data.
Upvotes: 6