* Re: [lm-sensors] i2c device w/o registers
2011-06-07 0:25 [lm-sensors] i2c device w/o registers Randy
@ 2011-06-07 6:48 ` Jean Delvare
2011-06-07 8:18 ` Ben Dooks
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jean Delvare @ 2011-06-07 6:48 UTC (permalink / raw)
To: lm-sensors
Hi Randy,
On Mon, 6 Jun 2011 17:25:10 -0700 (PDT), Randy wrote:
> I have an ADC (MCP3424) that doesn't use registers/commands.
>
> To configure the device, you simply write the configuration to the appropriate
> I2C device address.
>
> To read the sensor data, you simply issue a read to the device, which will
> return the ADC sample and the current control register (3 or 4 bytes total,
> depending on mode).
>
> All the commands in i2c-tools and the i2c drivers, except for the read/write
> byte commands, want to take an additional register parameter. This extra param
> going over the wire messes up the chip.
>
> Is there any simple way to support devices that don't support registers? I
> searched the archive, and found some requests for a i2c_smbus_read_word()
> command, but that's about it.
This question would have better been asked on the linux-i2c list,
methinks.
Anyway, the I2C commands you need aren't part of the SMBus command
subset, so you have to use raw I2C messaging. The functions you need
are i2c_master_send() and i2c_master_recv() in kernel space. In
user space, you'd simply call read() and write() on the device node. I
don't think there's any example of this in i2c-tools, but the i2c-dev
driver supports it.
--
Jean Delvare
_______________________________________________
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] i2c device w/o registers
2011-06-07 0:25 [lm-sensors] i2c device w/o registers Randy
2011-06-07 6:48 ` Jean Delvare
@ 2011-06-07 8:18 ` Ben Dooks
2011-06-07 18:57 ` Randy
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ben Dooks @ 2011-06-07 8:18 UTC (permalink / raw)
To: lm-sensors
On Mon, Jun 06, 2011 at 05:25:10PM -0700, Randy wrote:
> I have an ADC (MCP3424) that doesn't use registers/commands.
>
> To configure the device, you simply write the configuration to the appropriate
> I2C device address.
>
> To read the sensor data, you simply issue a read to the device, which will
> return the ADC sample and the current control register (3 or 4 bytes total,
> depending on mode).
>
> All the commands in i2c-tools and the i2c drivers, except for the read/write
> byte commands, want to take an additional register parameter. This extra param
> going over the wire messes up the chip.
>
> Is there any simple way to support devices that don't support registers? I
> searched the archive, and found some requests for a i2c_smbus_read_word()
> command, but that's about it.
you can send direct i2c commands to the device without any register
access by using i2c_transfer with an "struct i2c_msg" to do anything
you like.
--
Ben Dooks, ben@fluff.org, http://www.fluff.org/ben/
Large Hadron Colada: A large Pina Colada that makes the universe disappear.
_______________________________________________
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] i2c device w/o registers
2011-06-07 0:25 [lm-sensors] i2c device w/o registers Randy
2011-06-07 6:48 ` Jean Delvare
2011-06-07 8:18 ` Ben Dooks
@ 2011-06-07 18:57 ` Randy
2011-06-07 19:02 ` Guenter Roeck
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Randy @ 2011-06-07 18:57 UTC (permalink / raw)
To: lm-sensors
Thanks. I did the equivalent of this by modifying i2c_smbus_xfer_emulated() and
making my own read message, and it works.
Maybe I'll try to call i2c_transfer directly as your recommended, since that
sounds cleaner.
thanks,
Randy
----- Original Message ----
From: Ben Dooks <ben@trinity.fluff.org>
To: Randy <singularity_2@yahoo.com>
Cc: lm-sensors@lm-sensors.org
Sent: Tue, June 7, 2011 1:18:39 AM
Subject: Re: [lm-sensors] i2c device w/o registers
On Mon, Jun 06, 2011 at 05:25:10PM -0700, Randy wrote:
> I have an ADC (MCP3424) that doesn't use registers/commands.
>
> To configure the device, you simply write the configuration to the appropriate
> I2C device address.
>
> To read the sensor data, you simply issue a read to the device, which will
> return the ADC sample and the current control register (3 or 4 bytes total,
> depending on mode).
>
> All the commands in i2c-tools and the i2c drivers, except for the read/write
> byte commands, want to take an additional register parameter. This extra param
>
> going over the wire messes up the chip.
>
> Is there any simple way to support devices that don't support registers? I
> searched the archive, and found some requests for a i2c_smbus_read_word()
> command, but that's about it.
you can send direct i2c commands to the device without any register
access by using i2c_transfer with an "struct i2c_msg" to do anything
you like.
--
Ben Dooks, ben@fluff.org, http://www.fluff.org/ben/
Large Hadron Colada: A large Pina Colada that makes the universe disappear.
_______________________________________________
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] i2c device w/o registers
2011-06-07 0:25 [lm-sensors] i2c device w/o registers Randy
` (2 preceding siblings ...)
2011-06-07 18:57 ` Randy
@ 2011-06-07 19:02 ` Guenter Roeck
2011-06-08 22:25 ` Randy
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2011-06-07 19:02 UTC (permalink / raw)
To: lm-sensors
On Tue, Jun 07, 2011 at 02:57:59PM -0400, Randy wrote:
> Thanks. I did the equivalent of this by modifying i2c_smbus_xfer_emulated() and
> making my own read message, and it works.
>
> Maybe I'll try to call i2c_transfer directly as your recommended, since that
> sounds cleaner.
>
Might be a good idea, at least if you plan to submit your driver ;).
Guenter
_______________________________________________
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] i2c device w/o registers
2011-06-07 0:25 [lm-sensors] i2c device w/o registers Randy
` (3 preceding siblings ...)
2011-06-07 19:02 ` Guenter Roeck
@ 2011-06-08 22:25 ` Randy
2011-06-13 21:18 ` Randy
2011-06-16 20:11 ` Randy
6 siblings, 0 replies; 8+ messages in thread
From: Randy @ 2011-06-08 22:25 UTC (permalink / raw)
To: lm-sensors
read() and write() worked well. I just had to set the slave address w/ ioctl()
thanks,
Randy
----- Original Message ----
From: Jean Delvare <khali@linux-fr.org>
To: Randy <singularity_2@yahoo.com>
Cc: lm-sensors@lm-sensors.org
Sent: Mon, June 6, 2011 11:48:12 PM
Subject: Re: [lm-sensors] i2c device w/o registers
Hi Randy,
On Mon, 6 Jun 2011 17:25:10 -0700 (PDT), Randy wrote:
> I have an ADC (MCP3424) that doesn't use registers/commands.
>
> To configure the device, you simply write the configuration to the appropriate
> I2C device address.
>
> To read the sensor data, you simply issue a read to the device, which will
> return the ADC sample and the current control register (3 or 4 bytes total,
> depending on mode).
>
> All the commands in i2c-tools and the i2c drivers, except for the read/write
> byte commands, want to take an additional register parameter. This extra param
>
> going over the wire messes up the chip.
>
> Is there any simple way to support devices that don't support registers? I
> searched the archive, and found some requests for a i2c_smbus_read_word()
> command, but that's about it.
This question would have better been asked on the linux-i2c list,
methinks.
Anyway, the I2C commands you need aren't part of the SMBus command
subset, so you have to use raw I2C messaging. The functions you need
are i2c_master_send() and i2c_master_recv() in kernel space. In
user space, you'd simply call read() and write() on the device node. I
don't think there's any example of this in i2c-tools, but the i2c-dev
driver supports it.
--
Jean Delvare
_______________________________________________
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] i2c device w/o registers
2011-06-07 0:25 [lm-sensors] i2c device w/o registers Randy
` (4 preceding siblings ...)
2011-06-08 22:25 ` Randy
@ 2011-06-13 21:18 ` Randy
2011-06-16 20:11 ` Randy
6 siblings, 0 replies; 8+ messages in thread
From: Randy @ 2011-06-13 21:18 UTC (permalink / raw)
To: lm-sensors
Thanks Jean. The user-space method worked great.
For kernel space access, is there an easy way to get a reference to the i2c
client (struct i2c_client *client) to pass to i2c_master_recv(), since I can't
do open() via a kernel module? I've searched all around, but can't find such an
example. I think my system would be cleaner as a kernel module (my I2C devices
are ADCs, so I'd use a different analog driver over i2c for different chips in
my system, and they'd all publish common analog read commands...).
Thanks,
Randy
----- Original Message ----
From: Jean Delvare <khali@linux-fr.org>
To: Randy <singularity_2@yahoo.com>
Cc: lm-sensors@lm-sensors.org
Sent: Mon, June 6, 2011 11:48:12 PM
Subject: Re: [lm-sensors] i2c device w/o registers
Hi Randy,
On Mon, 6 Jun 2011 17:25:10 -0700 (PDT), Randy wrote:
> I have an ADC (MCP3424) that doesn't use registers/commands.
>
> To configure the device, you simply write the configuration to the appropriate
> I2C device address.
>
> To read the sensor data, you simply issue a read to the device, which will
> return the ADC sample and the current control register (3 or 4 bytes total,
> depending on mode).
>
> All the commands in i2c-tools and the i2c drivers, except for the read/write
> byte commands, want to take an additional register parameter. This extra param
>
> going over the wire messes up the chip.
>
> Is there any simple way to support devices that don't support registers? I
> searched the archive, and found some requests for a i2c_smbus_read_word()
> command, but that's about it.
This question would have better been asked on the linux-i2c list,
methinks.
Anyway, the I2C commands you need aren't part of the SMBus command
subset, so you have to use raw I2C messaging. The functions you need
are i2c_master_send() and i2c_master_recv() in kernel space. In
user space, you'd simply call read() and write() on the device node. I
don't think there's any example of this in i2c-tools, but the i2c-dev
driver supports it.
--
Jean Delvare
_______________________________________________
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] i2c device w/o registers
2011-06-07 0:25 [lm-sensors] i2c device w/o registers Randy
` (5 preceding siblings ...)
2011-06-13 21:18 ` Randy
@ 2011-06-16 20:11 ` Randy
6 siblings, 0 replies; 8+ messages in thread
From: Randy @ 2011-06-16 20:11 UTC (permalink / raw)
To: lm-sensors
I got it working by creating a very basic slave device driver for my ADC
converter.
For anyone in the same situation, there is a good link here:
http://www.embedded-bits.co.uk/?s=i2c
But you're right, this was probably more appropriate for the linux i2c list.
Thanks.
----- Original Message ----
From: Jean Delvare <khali@linux-fr.org>
To: Randy <singularity_2@yahoo.com>
Cc: lm-sensors@lm-sensors.org
Sent: Mon, June 6, 2011 11:48:12 PM
Subject: Re: [lm-sensors] i2c device w/o registers
Hi Randy,
On Mon, 6 Jun 2011 17:25:10 -0700 (PDT), Randy wrote:
> I have an ADC (MCP3424) that doesn't use registers/commands.
>
> To configure the device, you simply write the configuration to the appropriate
> I2C device address.
>
> To read the sensor data, you simply issue a read to the device, which will
> return the ADC sample and the current control register (3 or 4 bytes total,
> depending on mode).
>
> All the commands in i2c-tools and the i2c drivers, except for the read/write
> byte commands, want to take an additional register parameter. This extra param
>
> going over the wire messes up the chip.
>
> Is there any simple way to support devices that don't support registers? I
> searched the archive, and found some requests for a i2c_smbus_read_word()
> command, but that's about it.
This question would have better been asked on the linux-i2c list,
methinks.
Anyway, the I2C commands you need aren't part of the SMBus command
subset, so you have to use raw I2C messaging. The functions you need
are i2c_master_send() and i2c_master_recv() in kernel space. In
user space, you'd simply call read() and write() on the device node. I
don't think there's any example of this in i2c-tools, but the i2c-dev
driver supports it.
--
Jean Delvare
_______________________________________________
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