何时在 Linux 中最好地实现 I2C 驱动程序模块
我目前正在处理运行 Linux 的嵌入式系统中连接到 I2C 总线的两个设备。我正在使用第一个设备(相机)的现有驱动程序。对于第二个设备,我已经成功实现了一个用户空间程序,我可以通过该程序与第二个设备进行通信。到目前为止,这两种设备似乎可以愉快地共存。然而,几乎所有的I2C设备都有自己的驱动模块。因此,我想知道驱动程序模块的优点是什么。我查看了以下线程...
...但没有结论。
因此,与用户空间实现相比,编写 I2C 驱动程序模块有什么优势?
问候, 斯特凡
I am currently dealing with two devices connected to the I2C bus within an embedded system running Linux. I am using an exisiting driver for the first device, a camera. For the second device, I have successfully implemented a userspace program with which I can communicate with the second device. So far, both devices seem to coexist happily. However, almost all I2C devices have their own driver module. Thus, I am wondering what the advantages of a driver module are. I had a look at the following thread...
When should I write a Linux kernel module?
... but without conclusion.
Thus, what would be the advantage of writing a I2C driver module over a userspace implementation?
Regards,
Stefan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的情况下,您可能对 I2C 驱动程序模块没有太多用处。如果它没有损坏......
我要包含内核模块驱动程序的主要原因是当另一个内核模式驱动程序是 I2C 客户端时,或者受益于与内核的紧密集成。其中一个示例是 WM8350 音频编解码器,它通过音频总线(I2S 或 AC97)传输音频数据并通过 I2C 传输配置(例如音量级别)。
电源管理 IC 是您希望内核直接控制的芯片的另一个示例。
最后,我要指出的是,I2C 驱动程序有很多种。 (请参阅 Documentation/i2c/summary。)在某些情况下,您的硬件可能需要 I2C 总线适配器驱动程序,以教授如何通过 I2C 进行通信。这将需要内核模式驱动程序。
In your situation, you probably don't have much use for a I2C driver module. If it ain't broke....
The main reason I would include a kernel module driver is when another kernel mode driver is a I2C client, or benefits from tight integration with the kernel. One example of this is the WM8350 audio codec, which is communicates audio data over an audio bus (I2S or AC97) and configuration (e.g. volume level) over I2C.
A power management IC is another example of a chip that you would want the kernel to directly control.
Finally, I will note that there are multiple kinds of I2C drivers. (See Documentation/i2c/summary.) In some cases your hardware might require an I2C bus adapter driver, to teach how to communicate over I2C. That would require a kernel mode driver.