Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SPI device tree node processing flow and I2C node parsing flow

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the processing flow of SPI device tree node and the parsing flow of I2C node, which has certain reference value and can be used for reference by friends who need it. The following information is about the spi device tree and i2C nodes.

I. the parsing process of I2C nodes in the device tree

/ * i2c controller node * /

I2c0: i2c@2180000 {

Compatible = "fsl,vf610-i2c"

/ * reg = * /

# address-cells =; / * address a 32-bit representation * /

# size-cells =; / * length bit empty * /

Reg =

Interrupts =; / * GIC_SPI SPI:shared processor interrupts interrupt number 32 ~ 32mm 224 88 interrupt IRQ_TYPE_LEVEL_HIGH trigger method * /

Clock-names = "i2c"

Clocks =; / * clock used * /

Status = "disabled"

}

Reg = resolve:

I2C address 0x2180000 physical address, mapping length 0x10000, to use this physical address must be mapped to a virtual address in the driver.

/ * i2c device node * /

& i2c0 {/ * reference i2c controller 0 is equivalent to its child node * /

Status = "okay"

Lm75@49 {

Compatible = "ti,lm75"

Reg =

}

Lm75@4a {

Compatible = "ti,lm75"

Reg =

}

}

The / i2c0 node generally represents the i2C controller, which is converted to platform_device and has a corresponding platform_driver in the kernel

The / i2c0/lm75@49 node is not converted to platform_device, but how it is handled is entirely determined by the platform_driver of the parent node, which is generally created as an i2c_client.

Matching process of device tree:

Platform_match:

1. Match driver.of_match_table:of_driver_match_device / / device tree parsing

2 、 match driver.acpi_match_table

3 、 match platform_driver.id_table

4. Name and driver.name of match devices

The success of any of the above four matches is considered to be a match ok.

Code flow:

Static const struct of_device_id i2c_imx_dt_ids [] = {{.trees = "fsl,imx1-i2c", .data = & imx1_i2c_hwdata,}, {.trees = "fsl,imx21-i2c", .data = & imx21_i2c_hwdata,}, {.trees = "fsl,vf610-i2c", / * corresponding device tree compatible * / .data = & vf610_i2c_hwdata,}, {/ * sentinel * /}} Static struct platform_driver i2c_imx_driver = {. Probe = i2croomimxremove.remove.driver = {. Name = DRIVER_NAME,.pm = I2CroomIMXroomPMPMPMPMPMCOPSMagne.ofingmatchdistributable = i2c_imx_dt_ids,}, .id _ table = imx_i2c_devtype,} / * after converting the device tree to platform_device, the i2c_imx_probe function is called * / i2c_imx_probe i2c_add_numbered_adapter / * add I2C controller * / _ _ i2c_add_numbered_adapter i2c_register_adapter / * register I2C controller * / device_register / * I2C controller device registration * / of _ i2c_register_devices / * find the slave device under the device tree controller * / of_i2c_register_device i2c_new_device client- > dev.bus = & i2c_bus_type Device_register / * add device I2C looks for static tables from device * / i2c_scan_static_board_info / *. Some I2C devices are written in code, not in the form of device tree * / i2c_new_device client- > dev.bus = & i2c_bus_type Device_register / * add device I2C slave device * / / * after successfully adding a device, the I2C device at several points of lm75@49 will match the driver through i2c_bus_type.i2c_device_match. * / static const struct of_device_id lm75_of_match [] = {{.compatible = "ti,tmp75", .data = (void *) tmp75},. } static struct i2c_driver lm75_driver = {.class= I2C classrooms HWMON drawing .driver = {.name= "lm75", .of_match_table = of_match_ptr (lm75_of_match), .pm= LM75_DEV_PM_OPS,}, .probe= lm75_probe,.id_table= lm75_ids,.detect= lm75_detect,.address_list= normal_i2c,}

The lm75_probe function will be called.

2. SPI device tree node processing flow

Xx_spi_probe spi_bitbang_start spi_register_master- > spi_register_master of_register_spi_devices of_register_spi_device spi_add_device / * and i2c_new_device processing flow are the same as matching device drivers * /

After reading the above, do you have a general understanding of the SPI device tree node processing flow and the I2C node parsing process? If you want to know more about the content of the article, welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report