Linux drive I²C subsystem device Registration driver Registration Simple analysis

Source: Internet
Author: User

Linux Drive design is mainly based on layered separation of ideas, I²C subsystem is divided into I2cocre, adapter, and Device_driver layer, in fact, adapter is also a device, but it is our main control chip of the I²c control interface only, Our main control chip has several I²C interfaces there are several adapter;

I2ccore this layer of Linux has helped us to achieve, the main work is similar to the role of Platform bus, responsible for drvier and equipment registration, compared to platform more than a adapter of the registration management work, and I²c's data transmission and reception algorithm, Said the algorithm is a bit exaggerated, in fact, according to the communication protocol of I²C to do the transceiver timing;

Adapter this layer of general master chip manufacturers will provide, so also do not need to write their own, s3c2440 chip this layer is the use of s3c2410 adapter driver, the approximate framework is the use of platform virtual bus, I2ccore registered adapter drive;

Device_driver this side of the drive is required to write their own, which is mainly the driver of our external devices, such as some of the three-axis accelerometer interface, AT24C0X series of EEPROM and so on ... This part of the code is actually how to operate them, such as what data to send them can start them, what data they can read to the data.

According to the framework of I2ccore, Device_driver is divided into two parts, one is device registration, the other part is the registration of driver, on both sides to complete the registration, respectively, will call I2ccore match function, to match, Match and platform match in the same way, is by the name to match, but this name and platform's name is different; The following is a list of device and driver registration in the I2ccore call process, from the process can be seen matching, Binding and invoking the probe Function procedure on the driver side:

Register Device:

i2c_new_device    device_register        device_add            bus_probe_device                /** *                  Device_attach                    /**/                    device_bind_driver                        / **                         /Driver_deferred_probe_del (dev);                     Driver_deferred_probe_trigger ();

Registration driver:

i2c_register_driver driver_register bus_add_driver Driver_attach/*no device on the bus rotation match, actually call __driver_attach function to match*/Bus_for_each_dev (DRV-bus, NULL, DRV, __driver_attach); if(!dev->driver)//If the device is not yet bound driverDriver_probe_device (DRV, Dev); RET=really_probe (Dev, DRV); Dev->driver = DRV;//device and Driver bindingsret = Drv->probe (dev);//call driver's probeDriver_bound (Dev);//device and Driver bindings

The summary is to write an i²c device driver, and platform virtual bus consistent, but finally registered to the I²C bus only, Linux drive or the use of separate layered thinking design drive.

Linux drive I²C subsystem device Registration driver Registration Simple analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.