* [lm-sensors] Application using i2c-imx.c
@ 2009-12-08 11:28 Javier Zugasti
2009-12-09 8:04 ` Jean Delvare
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Javier Zugasti @ 2009-12-08 11:28 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1.1: Type: text/plain, Size: 383 bytes --]
Hi everyone.
I wanted to ask if someone has used the i2c-imx driver functionalities to
communicate with a LM sensor. I haven't found a single example in the web
and I am very inexperienced with Linux.
If so, could you please let me have a look to the application code so that I
can understand how to communicate with my LM73 using the functions from the
mentioned driver?
Thanks.
[-- Attachment #1.2: Type: text/html, Size: 412 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] Application using i2c-imx.c
2009-12-08 11:28 [lm-sensors] Application using i2c-imx.c Javier Zugasti
@ 2009-12-09 8:04 ` Jean Delvare
2009-12-09 15:29 ` Javier Zugasti
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jean Delvare @ 2009-12-09 8:04 UTC (permalink / raw)
To: lm-sensors
Hi Javier,
On Tue, 8 Dec 2009 12:28:07 +0100, Javier Zugasti wrote:
> I wanted to ask if someone has used the i2c-imx driver functionalities to
> communicate with a LM sensor. I haven't found a single example in the web
> and I am very inexperienced with Linux.
You don't really have to care. Almost all I2C-based hwmon drivers
should work on top of any I2C bus driver. Exceptions are very rare (and
would suggest broken hardware design.)
> If so, could you please let me have a look to the application code so that I
> can understand how to communicate with my LM73 using the functions from the
> mentioned driver?
You don't have to do anything, drivers for this already exist. The lm73
driver isn't upstream yet, but it will be in a few days. For now you
can pick the patch from there:
ftp://ftp.kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-hwmon/hwmon-lm73-new-driver.patch
After patching your kernel tree, simply load the i2c-imx and lm73
drivers. Then either declare the lm73 device as part of your platform
data, or instantiate it from user-space using
the /sys/bus/i2c/devices/i2c-<n>/new_device file, where <n> is to be
replaced with the relevant i2c-imx's bus number (probably 0, if you
have a single I2C bus on your system.) And you should be done.
--
Jean Delvare
http://khali.linux-fr.org/wishlist.html
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] Application using i2c-imx.c
2009-12-08 11:28 [lm-sensors] Application using i2c-imx.c Javier Zugasti
2009-12-09 8:04 ` Jean Delvare
@ 2009-12-09 15:29 ` Javier Zugasti
2009-12-09 15:46 ` Jean Delvare
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Javier Zugasti @ 2009-12-09 15:29 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1.1: Type: text/plain, Size: 2274 bytes --]
Hi people,
Thank you very much for your reply Jean.
I patched the kernel tree with the patch you linked me to and then selected
the hwmon and lm73 option in the menuconfig options (together with the i2c
of course).
After that I used a cross-compiler to compile the kernel for my board and
transferred the images to my board and started my linux there.
I assume the system supports i2c now.
No i2c devices appear in the /dev directory or in /sys/bus/i2c/devices, but
the lm73 appears in /sys/bus/i2c/drivers and i2c appears in the file
/proc/devices:
cat /proc/devices
Character devices:
...
*89 i2c*
...
So now, how can I write an application in the user space that reads the
temperature from the lm73? Do I have to use IOCTL calls or how do I do it?
Thanks again for your help and excuse my ignorance.
Regards,
Javier
2009/12/9 Jean Delvare <khali@linux-fr.org>
> Hi Javier,
>
> On Tue, 8 Dec 2009 12:28:07 +0100, Javier Zugasti wrote:
> > I wanted to ask if someone has used the i2c-imx driver functionalities to
> > communicate with a LM sensor. I haven't found a single example in the web
> > and I am very inexperienced with Linux.
>
> You don't really have to care. Almost all I2C-based hwmon drivers
> should work on top of any I2C bus driver. Exceptions are very rare (and
> would suggest broken hardware design.)
>
> > If so, could you please let me have a look to the application code so
> that I
> > can understand how to communicate with my LM73 using the functions from
> the
> > mentioned driver?
>
> You don't have to do anything, drivers for this already exist. The lm73
> driver isn't upstream yet, but it will be in a few days. For now you
> can pick the patch from there:
>
>
> ftp://ftp.kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-hwmon/hwmon-lm73-new-driver.patch
>
> After patching your kernel tree, simply load the i2c-imx and lm73
> drivers. Then either declare the lm73 device as part of your platform
> data, or instantiate it from user-space using
> the /sys/bus/i2c/devices/i2c-<n>/new_device file, where <n> is to be
> replaced with the relevant i2c-imx's bus number (probably 0, if you
> have a single I2C bus on your system.) And you should be done.
>
> --
> Jean Delvare
> http://khali.linux-fr.org/wishlist.html
>
[-- Attachment #1.2: Type: text/html, Size: 3042 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] Application using i2c-imx.c
2009-12-08 11:28 [lm-sensors] Application using i2c-imx.c Javier Zugasti
2009-12-09 8:04 ` Jean Delvare
2009-12-09 15:29 ` Javier Zugasti
@ 2009-12-09 15:46 ` Jean Delvare
2009-12-09 16:12 ` Javier Zugasti
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jean Delvare @ 2009-12-09 15:46 UTC (permalink / raw)
To: lm-sensors
Hi Javier,
What about NOT TOP-POSTING, as I requested once already?
On Wed, 9 Dec 2009 16:29:34 +0100, Javier Zugasti wrote:
> Thank you very much for your reply Jean.
> I patched the kernel tree with the patch you linked me to and then selected
> the hwmon and lm73 option in the menuconfig options (together with the i2c
> of course).
>
> After that I used a cross-compiler to compile the kernel for my board and
> transferred the images to my board and started my linux there.
>
> I assume the system supports i2c now.
> No i2c devices appear in the /dev directory or in /sys/bus/i2c/devices
Which kernel are you running? I2C adapters only show
in /sys/bus/i2c/devices since kernel 2.6.32. For older kernels you
would look for them in /sys/class/i2c-adapter.
Assuming you run an older kernel, please list the entries
under /sys/class/i2c-adapter.
, but
> the lm73 appears in /sys/bus/i2c/drivers and i2c appears in the file
> /proc/devices:
>
> cat /proc/devices
> Character devices:
> ...
> *89 i2c*
> ...
This means i2c-dev is loaded, but you shouldn't need it, see below.
> So now, how can I write an application in the user space that reads the
> temperature from the lm73? Do I have to use IOCTL calls or how do I do it?
With the lm73 driver you're using, access to the LM73 chip is done
through sysfs, very easily. You would have to go through ioctls
on /dev/i2c* nodes only if you did _not_ have a kernel driver for the
LM73.
--
Jean Delvare
http://khali.linux-fr.org/wishlist.html
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] Application using i2c-imx.c
2009-12-08 11:28 [lm-sensors] Application using i2c-imx.c Javier Zugasti
` (2 preceding siblings ...)
2009-12-09 15:46 ` Jean Delvare
@ 2009-12-09 16:12 ` Javier Zugasti
2009-12-09 16:25 ` Jean Delvare
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Javier Zugasti @ 2009-12-09 16:12 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1.1: Type: text/plain, Size: 1952 bytes --]
Hi Jean,
2009/12/9 Jean Delvare <khali@linux-fr.org>
> Hi Javier,
>
> What about NOT TOP-POSTING, as I requested once already?
>
> On Wed, 9 Dec 2009 16:29:34 +0100, Javier Zugasti wrote:
> > Thank you very much for your reply Jean.
> > I patched the kernel tree with the patch you linked me to and then
> selected
> > the hwmon and lm73 option in the menuconfig options (together with the
> i2c
> > of course).
> >
> > After that I used a cross-compiler to compile the kernel for my board and
> > transferred the images to my board and started my linux there.
> >
> > I assume the system supports i2c now.
> > No i2c devices appear in the /dev directory or in /sys/bus/i2c/devices
>
> Which kernel are you running? I2C adapters only show
> in /sys/bus/i2c/devices since kernel 2.6.32. For older kernels you
> would look for them in /sys/class/i2c-adapter.
>
> Assuming you run an older kernel, please list the entries
> under /sys/class/i2c-adapter.
>
> I am using kernel 2.6.31, and there are no entries under
/sys/class/i2c-adapter:
*# ls /sys/class/i2c-*
/sys/class/i2c-adapter:
/sys/class/i2c-dev:
*
> , but
> > the lm73 appears in /sys/bus/i2c/drivers and i2c appears in the file
> > /proc/devices:
> >
> > cat /proc/devices
> > Character devices:
> > ...
> > *89 i2c*
> > ...
>
> This means i2c-dev is loaded, but you shouldn't need it, see below.
>
> > So now, how can I write an application in the user space that reads the
> > temperature from the lm73? Do I have to use IOCTL calls or how do I do
> it?
>
> With the lm73 driver you're using, access to the LM73 chip is done
> through sysfs, very easily. You would have to go through ioctls
> on /dev/i2c* nodes only if you did _not_ have a kernel driver for the
> LM73.
>
> OK. I'm going to go through the usage of sysfs and see how it goes. But I
guess it won't until the i2c-adapter appears, right?
> --
> Jean Delvare
> http://khali.linux-fr.org/wishlist.html
>
Thank you,
Javier
[-- Attachment #1.2: Type: text/html, Size: 3040 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] Application using i2c-imx.c
2009-12-08 11:28 [lm-sensors] Application using i2c-imx.c Javier Zugasti
` (3 preceding siblings ...)
2009-12-09 16:12 ` Javier Zugasti
@ 2009-12-09 16:25 ` Jean Delvare
2009-12-09 16:39 ` Javier Zugasti
2009-12-09 16:49 ` Jean Delvare
6 siblings, 0 replies; 8+ messages in thread
From: Jean Delvare @ 2009-12-09 16:25 UTC (permalink / raw)
To: lm-sensors
Hi Javier,
On Wed, 9 Dec 2009 17:12:12 +0100, Javier Zugasti wrote:
> 2009/12/9 Jean Delvare <khali@linux-fr.org>
> > With the lm73 driver you're using, access to the LM73 chip is done
> > through sysfs, very easily. You would have to go through ioctls
> > on /dev/i2c* nodes only if you did _not_ have a kernel driver for the
> > LM73.
> >
> > OK. I'm going to go through the usage of sysfs and see how it goes. But I
> guess it won't until the i2c-adapter appears, right?
Correct. You have to figure out why your I2C adapter isn't
instantiated. This isn't exactly on-topic on this mailing list...
You claim you'd use i2c-imx, how do you know? Did you actually build
that driver? If it is modular, did you load the module? Which machine
model are you using? i2c-imx is a platform driver, so the i2c-imx
device must be instantiated explicitly by the machine init code.
If you can't figure it out, it might be better to ask on list dedicated
to arm or even imx if there's one.
--
Jean Delvare
http://khali.linux-fr.org/wishlist.html
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] Application using i2c-imx.c
2009-12-08 11:28 [lm-sensors] Application using i2c-imx.c Javier Zugasti
` (4 preceding siblings ...)
2009-12-09 16:25 ` Jean Delvare
@ 2009-12-09 16:39 ` Javier Zugasti
2009-12-09 16:49 ` Jean Delvare
6 siblings, 0 replies; 8+ messages in thread
From: Javier Zugasti @ 2009-12-09 16:39 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1.1: Type: text/plain, Size: 1513 bytes --]
Hi
2009/12/9 Jean Delvare <khali@linux-fr.org>
> Hi Javier,
>
> On Wed, 9 Dec 2009 17:12:12 +0100, Javier Zugasti wrote:
> > 2009/12/9 Jean Delvare <khali@linux-fr.org>
> > > With the lm73 driver you're using, access to the LM73 chip is done
> > > through sysfs, very easily. You would have to go through ioctls
> > > on /dev/i2c* nodes only if you did _not_ have a kernel driver for the
> > > LM73.
> > >
> > > OK. I'm going to go through the usage of sysfs and see how it goes. But
> I
> > guess it won't until the i2c-adapter appears, right?
>
> Correct. You have to figure out why your I2C adapter isn't
> instantiated. This isn't exactly on-topic on this mailing list...
>
> You claim you'd use i2c-imx, how do you know? Did you actually build
> that driver? If it is modular, did you load the module? Which machine
> model are you using? i2c-imx is a platform driver, so the i2c-imx
> device must be instantiated explicitly by the machine init code.
>
> Well, in the I2C support from menuconfig I selected the following options:
<*> I2C support --->
<*> I2C device interface
I2C Hardware Bus Support --->
<*> IMX I2C interface
Should I just select I2C support and then use sysfs as you suggested before?
Could this be the reason why my I2C adapter isn't
instantiated?
> If you can't figure it out, it might be better to ask on list dedicated
> to arm or even imx if there's one.
>
> --
> Jean Delvare
> http://khali.linux-fr.org/wishlist.html
>
Thanks,
Javier
[-- Attachment #1.2: Type: text/html, Size: 2378 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] Application using i2c-imx.c
2009-12-08 11:28 [lm-sensors] Application using i2c-imx.c Javier Zugasti
` (5 preceding siblings ...)
2009-12-09 16:39 ` Javier Zugasti
@ 2009-12-09 16:49 ` Jean Delvare
6 siblings, 0 replies; 8+ messages in thread
From: Jean Delvare @ 2009-12-09 16:49 UTC (permalink / raw)
To: lm-sensors
On Wed, 9 Dec 2009 17:39:33 +0100, Javier Zugasti wrote:
> 2009/12/9 Jean Delvare <khali@linux-fr.org>
> > You claim you'd use i2c-imx, how do you know? Did you actually build
> > that driver? If it is modular, did you load the module? Which machine
> > model are you using? i2c-imx is a platform driver, so the i2c-imx
> > device must be instantiated explicitly by the machine init code.
>
> Well, in the I2C support from menuconfig I selected the following options:
>
> <*> I2C support --->
> <*> I2C device interface
> I2C Hardware Bus Support --->
> <*> IMX I2C interface
>
> Should I just select I2C support and then use sysfs as you suggested before?
No, this suggestion of mine was unrelated.
> Could this be the reason why my I2C adapter isn't instantiated?
No. If the driver is properly build in, then I suspect that the device
itself is missing. Just check in /sys/devices/platform/ if it's there
or not. If not then something's missing in your machine init data.
--
Jean Delvare
http://khali.linux-fr.org/wishlist.html
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-12-09 16:49 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-08 11:28 [lm-sensors] Application using i2c-imx.c Javier Zugasti
2009-12-09 8:04 ` Jean Delvare
2009-12-09 15:29 ` Javier Zugasti
2009-12-09 15:46 ` Jean Delvare
2009-12-09 16:12 ` Javier Zugasti
2009-12-09 16:25 ` Jean Delvare
2009-12-09 16:39 ` Javier Zugasti
2009-12-09 16:49 ` Jean Delvare
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.