How to pass board specific info to I2C driver module

发布于 2022-09-22 13:07:36 字数 889 浏览 12 评论 0

Hi All,

I'm working on an ADC chip (MCP3021) driver under Linux 2.6.27.
We used these two chips to monitor the CPU core current and
platform current individually, which is converted to voltage as
the ADC chip's input.
As you know, the driver shouldn't contain the board specific info,
such as, the chip's work voltage, the ratio of voltage and current.
So how to pass these info to the driver module?

Here is the way I can think of:
1. to use dts file to pass the info to the module.
    This way make the driver is bound to OF implement.

2. to use the module parameter.
    For different chips, the work voltage and the ratio may be different,
    but the chip uses the same driver.

Any other idea? Please give me some advice. Thanks a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

故事与诗 2022-09-29 13:07:36

Your question is that how the kernel space to communicate with the userspace?
If so, I suggest you read some articles on the website of IBM developer.

岁月静好 2022-09-29 13:07:36

Thanks for you reply.

It doesn't matter. I just want to make it to be a general driver.
So I must handle the individual parameter of the different chips in the driver.

习惯成性 2022-09-29 13:07:36

Your application is very special
I wish you can share your design and ideas.

北方的巷 2022-09-29 13:07:36

I do not think the methods you mentioned are good enough, for example, if you pass a module parameter to your module, and it is initialized using this parameter, how do you differentiate your Vdds?

I suggest that you could use the parameters when you call ioctl/read, you can define a struct like this:
struct para
{
    int vdd;//in mini V
    int vin; // in mini V
};

then when you call ioctl, first assign the vdd to para, then the driver can read the value back and do the trans, return the vin back to your application.

using this way, your driver can deal with all kinds of Vdds, right?

醉殇 2022-09-29 13:07:36

Good suggestion!
But I really don't quite understand what his real attempt!

浅黛梨妆こ 2022-09-29 13:07:36

First thanks for you guys reply.

yeah, bluesky_jxc's method will work, but the question is that
we don't write the application, the user get the voltage info through
sysfs or lm-sensors tool.

so far, I just pass the vdd info to driver through module parameter or
kernel parameter(if builtin), and give the voltage info through sysfs
(lm-sensors tool also can get the info).

天煞孤星 2022-09-29 13:07:36

I don't think so.....

How can different modules with different Vdds share your driver if you use the
module parameter? if one uses Vdd=2.5V and the other uses Vdd=1.8V, how can
you tell the driver when to use 2.5 or 1.8?

Please take care, because your driver may be used for many chips with different
Vdds, not  just the one you are using now .

长安忆 2022-09-29 13:07:36

yes, there is an assumption. Generally, it's all 3.3V.

It's a little weird and hard issue for hw engineer that
the same type chip on the same bus uses different Vdd.

梦与时光遇 2022-09-29 13:07:36

Provide mechanism, not policy, if you want to provide a good driver.
But if you just want to make it work, any way will be OK

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文