i2c 设备注册过程

设备模型

由 总线(bus_type) + 设备(device) + 驱动(device_driver) 组成,在该模型下,所有的设备通过总线连接起来,即使有些设备没有连接到一根物理总线上,linux为其设置了一个内部的、虚拟的platform总线,用以维持总线、驱动、设备的关系。

因此,对于实现一个linux下的设备驱动,可以划分为两大步:

1、设备注册;

2、驱动注册。

下面是i2c_driver的调用流程:

i2c 设备注册过程_第1张图片

 

 

 

 kernel版本是4.4的,这里驱动注册已经完了,每个i2c client都有个adapter,这个如何生成的还待追查

以上过程也可以使用与platform_driver spi_driver

 

 

下面附上加的log打印
[    6.985224] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow i am tpd_local_init 1008
[    6.985230] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow i am i2c_register_driver 1878
[    6.985241] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow i am bus_add_driver 681
[    6.985284] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow i am bus_for_each_dev 307
[    6.985291] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    6.985303] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow i am driver_probe_device 434
[    6.985307] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow bus: 'i2c': driver_probe_device: matched device 0-005d with driver gt1x
[    6.985323] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow i am really_probe 295
[    6.985327] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow bus: 'i2c': really_probe: probing driver gt1x with device 0-005d
[    6.985508] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow i am really_probe 323


[    6.985527] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    6.985532] <0>.(6)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141468] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141483] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141490] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141500] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141511] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141518] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141527] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141538] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141545] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141555] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141567] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141574] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141583] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141594] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141601] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141610] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141621] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141628] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141637] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141648] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141655] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141665] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141677] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141684] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141694] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141705] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141712] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141722] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141733] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141740] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141749] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141760] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141767] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141777] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141787] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141795] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141803] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141814] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141821] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141831] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141841] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141849] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141858] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141869] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141876] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141886] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141897] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141904] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141913] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141925] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141932] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141943] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141954] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141961] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x
[    7.141970] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_device_match 512
[    7.141981] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_match_id 494
[    7.141988] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am  i2c_match_id 497  id->name = gt1x


[    7.142198] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_for_each_dev 1851
[    7.142212] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am bus_for_each_dev 307
[    7.142221] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142229] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142238] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142246] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142253] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142261] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142269] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142277] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142285] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142292] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142300] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142307] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142315] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142323] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142331] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142338] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142346] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142354] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142361] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142369] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142378] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142386] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142394] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142401] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142409] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142417] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142425] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142432] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142440] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142448] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142456] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142463] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142471] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142479] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142487] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142494] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142502] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142509] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142517] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142524] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142532] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142539] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458
[    7.142547] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am __process_new_driver 1863
[    7.142554] <0>.(2)[71:kworker/u16:2]memsic_i2c_flow i am i2c_detect 2458

 

 

你可能感兴趣的:(kernel)