2010-05-27 03:55:56     ADE7758/IIO driver/sub-system

Document created by Aaronwu Employee on Aug 21, 2013
Version 1Show Document
  • View in full screen mode

2010-05-27 03:55:56     ADE7758/IIO driver/sub-system

Allister Mannion (AFGHANISTAN)

Message: 89907   

 

We (NoWatt) use your (Analog) ADE7758 metering chip. We are currently

designing a new Atmel Linux-based product, and I was delighted to find

your ade7758 driver. I ported it to our generic Linux (2.6.31 based)

prototype, and had no problem adding .../IIO/* to the build.

 

Running the new kernel, installing (insmod-ing) the (Atmel) SPI,

(Analog) IIO, and (Analog) ade7758 modules, showed (via debug messages)

your driver initializing. Using a logic analyzer we saw your driver

read, then reset the ADE7758's interrupt mask, and on unloading

(the .ko) reading/writing the opcode register. It work - thanks!

 

I do however have a couple of questions if you wouldn't mind:

 

1. Not being an expert in the SPI Linux sub-system, and even after

reading your driver, I'm still at a loss as to how I drive the chip from

a user program. I can open the created /dev/device0:event0 device, but

then what? read/writes don't seem to make much sense as the chip select

needs to remain active between operations. Looking at your driver

reveals you provide IIO_ATTRIBUTE... defines, but I don't know how to

access then from userspace (ioctl?). Do you have any user program

samples?

 

2. I see during the build that I mustn't enable CONFIG_IIO_RING_BUFFER

for the ade7758 driver (otherwise routines like ade7753_configure_ring

remain undefined). Not defining this, enables 'stubs' in ade7758.h. Does

this mean the driver doesn't (fully?) use the Analog IIO sub-system? I

ask because I realize to use the ade7758, I will need the type of

functionality (I think) IIO provides. In particular, if I want to read

the waveform register, or anything else that can signal its readiness

via ADE7758 interrupts, I will need the driver to handle the ADE

interrupt and perform the read (adding the result to the ring, creating

a trigger????). Am I right in assuming there is work to do if I want to

handle the ADE's interrupts?

 

Many thanks for your help,

QuoteReplyEditDelete

 

 

2010-05-27 04:12:19     ADE7758/IIO driver/sub-system

Michael Hennerich (GERMANY)

Message: 89908    Allister,

 

Barry Song the author, can probably tell more.

But taking a quick look at the source.

The driver generates a fairly large list of sysfs entries under /sys/bus/iio/deviceX

If you use some older source it could be also under /sys/class/iio/deviceX.

 

These entries allow you to control or receive data from the controller.

Besides that, iio may support an triggered event interface.

However looking the source tells me that this is work in progress.

 

if (spi->irq) {

#if 0 /* fixme: here we should support */

iio_init_work_cont(&st->work_cont_thresh,

NULL,

ade7758_thresh_handler_bh_no_check,

0,

0,

st);

#endif

 

-Michael

QuoteReplyEditDelete

 

 

2010-05-27 04:32:34     ADE7758/IIO driver/sub-system

Allister Mannion (AFGHANISTAN)

Message: 89909    > (enter your response here)

QuoteReplyEditDelete

 

 

2010-05-27 06:13:53     Re: ADE7758/IIO driver/sub-system

Barry Song (CHINA)

Message: 89912   

 

Allister,

 

As Michael said, you can read /sys nodes to get values from ADE7758.  But that driver has not been tested yet and  IIO_RING_BUFFER codes have not been filled too.

 

-barry

QuoteReplyEditDelete

 

 

2010-05-29 17:37:46     Re: ADE7758/IIO driver/sub-system

Allister Mannion (AFGHANISTAN)

Message: 89992   

 

Thanks Barry; I think I can see this.

 

Could you confirm that reading from any of the /sys entries will create the expected SPI traffic (we see this on the SPI bus), but return '0' in all cases (e.g. cat airms returns 0).

 

I tried enabling 'Enable ring buffer support within IIO, Industrial I/O lock free software rin, and 'Enable triggered sample support", but the build then fails with:

 

ERROR: "ade7758_probe_trigger" [drivers/staging/iio/meter/ade7758.ko] undefined!

ERROR: "ade7758_initialize_ring" [drivers/staging/iio/meter/ade7758.ko] undefined!

ERROR: "ade7758_configure_ring" [drivers/staging/iio/meter/ade7758.ko] undefined!

ERROR: "ade7758_unconfigure_ring" [drivers/staging/iio/meter/ade7758.ko] undefined!

ERROR: "ade7758_uninitialize_ring" [drivers/staging/iio/meter/ade7758.ko] undefined!

ERROR: "ade7758_remove_trigger" [drivers/staging/iio/meter/ade7758.ko] undefined!

 

 

(as expected). So is this right, I won't be able to read any values (into userspace) until these routines are implemented and the driver is hooked up to the ring?

 

BTW, I think the ade7758_spi_read_reg_24 routine in ade7758.c should set .len = 4 (line 186), not 3. Correcting this results in the expected number (32) of clocks cycles on the SPI bus.

 

Allister

QuoteReplyEditDelete

 

 

2010-05-30 22:20:38     Re: ADE7758/IIO driver/sub-system

Barry Song (CHINA)

Message: 90005   

 

ring is not necessary for you to read value. I think there are two issues you should make sure:

 

1. setting right spi cs and mode in board file according to your board

 

2.adjust spi baud rate slower to check.

 

I have no hardware to test. If you have any patch after testing, can you send to us?

 

 

 

Yes. ade7758_spi_read_reg_24 routine in ade7758.c should set .len = 4.  It is typo.

 

Thanks

 

barry

Attachments

    Outcomes