節(jié)點(diǎn)創(chuàng)建
i2c_add_adapter、i2c_add_numbered_adapter 是注冊(cè) i2c_adapter,這兩個(gè) API 最終是調(diào)用 i2c_register_adapter。
static int i2c_register_adapter(struct i2c_adapter *adap)
{
......
dev_set_name(&adap- >dev, "i2c-%d", adap- >nr);
adap- >dev.bus = &i2c_bus_type;
adap- >dev.type = &i2c_adapter_type;
res = device_register(&adap- >dev);
/* create pre-declared device nodes */
of_i2c_register_devices(adap);
i2c_acpi_install_space_handler(adap);
i2c_acpi_register_devices(adap);
.....
}
dev_set_name(&adap->dev, "i2c-%d", adap->nr) 會(huì)在 Linux 中自動(dòng)創(chuàng)建 /sys/devices/platform/11f00000.i2c6/i2c-6 節(jié)點(diǎn)。
of_i2c_register_devices 會(huì)調(diào)用 i2c_new_client_device
struct i2c_client *i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
{
......
client- >dev.parent = &client- >adapter- >dev;
client- >dev.bus = &i2c_bus_type;
client- >dev.type = &i2c_client_type;
client- >dev.of_node = of_node_get(info- >of_node);
client- >dev.fwnode = info- >fwnode;
device_enable_async_suspend(&client- >dev);
i2c_dev_set_name(adap, client, info);
......
status = device_register(&client- >dev);
......
}
i2c_dev_set_name 會(huì)在 Linux 系統(tǒng)中自動(dòng)創(chuàng)建 /sys/devices/platform/11f00000.i2c6/i2c-6/6-0058 ,這里是掛在某個(gè) i2c bus 上的,從機(jī)地址為 0x58 的設(shè)備節(jié)點(diǎn)。
到這里,大家應(yīng)該能看懂下圖,這些節(jié)點(diǎn)在 I2C 控制器驅(qū)動(dòng)加載時(shí),自動(dòng)創(chuàng)建的。大家在 I2C 控制器的子節(jié)點(diǎn)中聲明的 I2C 從機(jī)設(shè)備,也會(huì)在這一步創(chuàng)建節(jié)點(diǎn)。
-
控制器
+關(guān)注
關(guān)注
112文章
16133瀏覽量
177143 -
節(jié)點(diǎn)
+關(guān)注
關(guān)注
0文章
217瀏覽量
24367 -
I2C
+關(guān)注
關(guān)注
28文章
1477瀏覽量
123104
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論