2 * ADE7758 Poly Phase Multifunction Energy Metering IC driver
4 * Copyright 2010-2011 Analog Devices Inc.
6 * Licensed under the GPL-2.
9 #include <linux/interrupt.h>
10 #include <linux/irq.h>
11 #include <linux/gpio.h>
12 #include <linux/delay.h>
13 #include <linux/mutex.h>
14 #include <linux/device.h>
15 #include <linux/kernel.h>
16 #include <linux/spi/spi.h>
17 #include <linux/slab.h>
18 #include <linux/sysfs.h>
19 #include <linux/list.h>
23 #include "../ring_generic.h"
27 int ade7758_spi_write_reg_8(struct device
*dev
,
32 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
33 struct ade7758_state
*st
= iio_priv(indio_dev
);
35 mutex_lock(&st
->buf_lock
);
36 st
->tx
[0] = ADE7758_WRITE_REG(reg_address
);
39 ret
= spi_write(st
->us
, st
->tx
, 2);
40 mutex_unlock(&st
->buf_lock
);
45 static int ade7758_spi_write_reg_16(struct device
*dev
,
50 struct spi_message msg
;
51 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
52 struct ade7758_state
*st
= iio_priv(indio_dev
);
53 struct spi_transfer xfers
[] = {
61 mutex_lock(&st
->buf_lock
);
62 st
->tx
[0] = ADE7758_WRITE_REG(reg_address
);
63 st
->tx
[1] = (value
>> 8) & 0xFF;
64 st
->tx
[2] = value
& 0xFF;
66 spi_message_init(&msg
);
67 spi_message_add_tail(xfers
, &msg
);
68 ret
= spi_sync(st
->us
, &msg
);
69 mutex_unlock(&st
->buf_lock
);
74 static int ade7758_spi_write_reg_24(struct device
*dev
,
79 struct spi_message msg
;
80 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
81 struct ade7758_state
*st
= iio_priv(indio_dev
);
82 struct spi_transfer xfers
[] = {
90 mutex_lock(&st
->buf_lock
);
91 st
->tx
[0] = ADE7758_WRITE_REG(reg_address
);
92 st
->tx
[1] = (value
>> 16) & 0xFF;
93 st
->tx
[2] = (value
>> 8) & 0xFF;
94 st
->tx
[3] = value
& 0xFF;
96 spi_message_init(&msg
);
97 spi_message_add_tail(xfers
, &msg
);
98 ret
= spi_sync(st
->us
, &msg
);
99 mutex_unlock(&st
->buf_lock
);
104 int ade7758_spi_read_reg_8(struct device
*dev
,
108 struct spi_message msg
;
109 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
110 struct ade7758_state
*st
= iio_priv(indio_dev
);
112 struct spi_transfer xfers
[] = {
120 .tx_buf
= &st
->tx
[1],
127 mutex_lock(&st
->buf_lock
);
128 st
->tx
[0] = ADE7758_READ_REG(reg_address
);
131 spi_message_init(&msg
);
132 spi_message_add_tail(&xfers
[0], &msg
);
133 spi_message_add_tail(&xfers
[1], &msg
);
134 ret
= spi_sync(st
->us
, &msg
);
136 dev_err(&st
->us
->dev
, "problem when reading 8 bit register 0x%02X",
143 mutex_unlock(&st
->buf_lock
);
147 static int ade7758_spi_read_reg_16(struct device
*dev
,
151 struct spi_message msg
;
152 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
153 struct ade7758_state
*st
= iio_priv(indio_dev
);
155 struct spi_transfer xfers
[] = {
163 .tx_buf
= &st
->tx
[1],
171 mutex_lock(&st
->buf_lock
);
172 st
->tx
[0] = ADE7758_READ_REG(reg_address
);
176 spi_message_init(&msg
);
177 spi_message_add_tail(&xfers
[0], &msg
);
178 spi_message_add_tail(&xfers
[1], &msg
);
179 ret
= spi_sync(st
->us
, &msg
);
181 dev_err(&st
->us
->dev
, "problem when reading 16 bit register 0x%02X",
186 *val
= (st
->rx
[0] << 8) | st
->rx
[1];
189 mutex_unlock(&st
->buf_lock
);
193 static int ade7758_spi_read_reg_24(struct device
*dev
,
197 struct spi_message msg
;
198 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
199 struct ade7758_state
*st
= iio_priv(indio_dev
);
201 struct spi_transfer xfers
[] = {
209 .tx_buf
= &st
->tx
[1],
216 mutex_lock(&st
->buf_lock
);
217 st
->tx
[0] = ADE7758_READ_REG(reg_address
);
222 spi_message_init(&msg
);
223 spi_message_add_tail(&xfers
[0], &msg
);
224 spi_message_add_tail(&xfers
[1], &msg
);
225 ret
= spi_sync(st
->us
, &msg
);
227 dev_err(&st
->us
->dev
, "problem when reading 24 bit register 0x%02X",
231 *val
= (st
->rx
[0] << 16) | (st
->rx
[1] << 8) | st
->rx
[2];
234 mutex_unlock(&st
->buf_lock
);
238 static ssize_t
ade7758_read_8bit(struct device
*dev
,
239 struct device_attribute
*attr
,
244 struct iio_dev_attr
*this_attr
= to_iio_dev_attr(attr
);
246 ret
= ade7758_spi_read_reg_8(dev
, this_attr
->address
, &val
);
250 return sprintf(buf
, "%u\n", val
);
253 static ssize_t
ade7758_read_16bit(struct device
*dev
,
254 struct device_attribute
*attr
,
259 struct iio_dev_attr
*this_attr
= to_iio_dev_attr(attr
);
261 ret
= ade7758_spi_read_reg_16(dev
, this_attr
->address
, &val
);
265 return sprintf(buf
, "%u\n", val
);
268 static ssize_t
ade7758_read_24bit(struct device
*dev
,
269 struct device_attribute
*attr
,
274 struct iio_dev_attr
*this_attr
= to_iio_dev_attr(attr
);
276 ret
= ade7758_spi_read_reg_24(dev
, this_attr
->address
, &val
);
280 return sprintf(buf
, "%u\n", val
& 0xFFFFFF);
283 static ssize_t
ade7758_write_8bit(struct device
*dev
,
284 struct device_attribute
*attr
,
288 struct iio_dev_attr
*this_attr
= to_iio_dev_attr(attr
);
292 ret
= strict_strtol(buf
, 10, &val
);
295 ret
= ade7758_spi_write_reg_8(dev
, this_attr
->address
, val
);
298 return ret
? ret
: len
;
301 static ssize_t
ade7758_write_16bit(struct device
*dev
,
302 struct device_attribute
*attr
,
306 struct iio_dev_attr
*this_attr
= to_iio_dev_attr(attr
);
310 ret
= strict_strtol(buf
, 10, &val
);
313 ret
= ade7758_spi_write_reg_16(dev
, this_attr
->address
, val
);
316 return ret
? ret
: len
;
319 static int ade7758_reset(struct device
*dev
)
323 ade7758_spi_read_reg_8(dev
,
326 val
|= 1 << 6; /* Software Chip Reset */
327 ret
= ade7758_spi_write_reg_8(dev
,
334 static ssize_t
ade7758_write_reset(struct device
*dev
,
335 struct device_attribute
*attr
,
336 const char *buf
, size_t len
)
344 return ade7758_reset(dev
);
349 static IIO_DEV_ATTR_VPEAK(S_IWUSR
| S_IRUGO
,
353 static IIO_DEV_ATTR_IPEAK(S_IWUSR
| S_IRUGO
,
357 static IIO_DEV_ATTR_APHCAL(S_IWUSR
| S_IRUGO
,
361 static IIO_DEV_ATTR_BPHCAL(S_IWUSR
| S_IRUGO
,
365 static IIO_DEV_ATTR_CPHCAL(S_IWUSR
| S_IRUGO
,
369 static IIO_DEV_ATTR_WDIV(S_IWUSR
| S_IRUGO
,
373 static IIO_DEV_ATTR_VADIV(S_IWUSR
| S_IRUGO
,
377 static IIO_DEV_ATTR_AIRMS(S_IRUGO
,
381 static IIO_DEV_ATTR_BIRMS(S_IRUGO
,
385 static IIO_DEV_ATTR_CIRMS(S_IRUGO
,
389 static IIO_DEV_ATTR_AVRMS(S_IRUGO
,
393 static IIO_DEV_ATTR_BVRMS(S_IRUGO
,
397 static IIO_DEV_ATTR_CVRMS(S_IRUGO
,
401 static IIO_DEV_ATTR_AIRMSOS(S_IWUSR
| S_IRUGO
,
405 static IIO_DEV_ATTR_BIRMSOS(S_IWUSR
| S_IRUGO
,
409 static IIO_DEV_ATTR_CIRMSOS(S_IWUSR
| S_IRUGO
,
413 static IIO_DEV_ATTR_AVRMSOS(S_IWUSR
| S_IRUGO
,
417 static IIO_DEV_ATTR_BVRMSOS(S_IWUSR
| S_IRUGO
,
421 static IIO_DEV_ATTR_CVRMSOS(S_IWUSR
| S_IRUGO
,
425 static IIO_DEV_ATTR_AIGAIN(S_IWUSR
| S_IRUGO
,
429 static IIO_DEV_ATTR_BIGAIN(S_IWUSR
| S_IRUGO
,
433 static IIO_DEV_ATTR_CIGAIN(S_IWUSR
| S_IRUGO
,
437 static IIO_DEV_ATTR_AVRMSGAIN(S_IWUSR
| S_IRUGO
,
441 static IIO_DEV_ATTR_BVRMSGAIN(S_IWUSR
| S_IRUGO
,
445 static IIO_DEV_ATTR_CVRMSGAIN(S_IWUSR
| S_IRUGO
,
450 int ade7758_set_irq(struct device
*dev
, bool enable
)
454 ret
= ade7758_spi_read_reg_24(dev
, ADE7758_MASK
, &irqen
);
459 irqen
|= 1 << 16; /* Enables an interrupt when a data is
460 present in the waveform register */
464 ret
= ade7758_spi_write_reg_24(dev
, ADE7758_MASK
, irqen
);
472 /* Power down the device */
473 static int ade7758_stop_device(struct device
*dev
)
477 ade7758_spi_read_reg_8(dev
,
480 val
|= 7 << 3; /* ADE7758 powered down */
481 ret
= ade7758_spi_write_reg_8(dev
,
488 static int ade7758_initial_setup(struct iio_dev
*indio_dev
)
490 struct ade7758_state
*st
= iio_priv(indio_dev
);
491 struct device
*dev
= &indio_dev
->dev
;
494 /* use low spi speed for init */
495 st
->us
->mode
= SPI_MODE_1
;
499 ret
= ade7758_set_irq(dev
, false);
501 dev_err(dev
, "disable irq failed");
506 msleep(ADE7758_STARTUP_DELAY
);
512 static ssize_t
ade7758_read_frequency(struct device
*dev
,
513 struct device_attribute
*attr
,
519 ret
= ade7758_spi_read_reg_8(dev
,
526 sps
= 26040 / (1 << t
);
528 len
= sprintf(buf
, "%d SPS\n", sps
);
532 static ssize_t
ade7758_write_frequency(struct device
*dev
,
533 struct device_attribute
*attr
,
537 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
542 ret
= strict_strtol(buf
, 10, &val
);
546 mutex_lock(&indio_dev
->mlock
);
566 ret
= ade7758_spi_read_reg_8(dev
,
575 ret
= ade7758_spi_write_reg_8(dev
,
580 mutex_unlock(&indio_dev
->mlock
);
582 return ret
? ret
: len
;
585 static IIO_DEV_ATTR_TEMP_RAW(ade7758_read_8bit
);
586 static IIO_CONST_ATTR(temp_offset
, "129 C");
587 static IIO_CONST_ATTR(temp_scale
, "4 C");
589 static IIO_DEV_ATTR_AWATTHR(ade7758_read_16bit
,
591 static IIO_DEV_ATTR_BWATTHR(ade7758_read_16bit
,
593 static IIO_DEV_ATTR_CWATTHR(ade7758_read_16bit
,
595 static IIO_DEV_ATTR_AVARHR(ade7758_read_16bit
,
597 static IIO_DEV_ATTR_BVARHR(ade7758_read_16bit
,
599 static IIO_DEV_ATTR_CVARHR(ade7758_read_16bit
,
601 static IIO_DEV_ATTR_AVAHR(ade7758_read_16bit
,
603 static IIO_DEV_ATTR_BVAHR(ade7758_read_16bit
,
605 static IIO_DEV_ATTR_CVAHR(ade7758_read_16bit
,
608 static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR
| S_IRUGO
,
609 ade7758_read_frequency
,
610 ade7758_write_frequency
);
612 static IIO_DEV_ATTR_RESET(ade7758_write_reset
);
614 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26040 13020 6510 3255");
616 static struct attribute
*ade7758_attributes
[] = {
617 &iio_dev_attr_temp_raw
.dev_attr
.attr
,
618 &iio_const_attr_temp_offset
.dev_attr
.attr
,
619 &iio_const_attr_temp_scale
.dev_attr
.attr
,
620 &iio_dev_attr_sampling_frequency
.dev_attr
.attr
,
621 &iio_const_attr_sampling_frequency_available
.dev_attr
.attr
,
622 &iio_dev_attr_reset
.dev_attr
.attr
,
623 &iio_dev_attr_awatthr
.dev_attr
.attr
,
624 &iio_dev_attr_bwatthr
.dev_attr
.attr
,
625 &iio_dev_attr_cwatthr
.dev_attr
.attr
,
626 &iio_dev_attr_avarhr
.dev_attr
.attr
,
627 &iio_dev_attr_bvarhr
.dev_attr
.attr
,
628 &iio_dev_attr_cvarhr
.dev_attr
.attr
,
629 &iio_dev_attr_avahr
.dev_attr
.attr
,
630 &iio_dev_attr_bvahr
.dev_attr
.attr
,
631 &iio_dev_attr_cvahr
.dev_attr
.attr
,
632 &iio_dev_attr_vpeak
.dev_attr
.attr
,
633 &iio_dev_attr_ipeak
.dev_attr
.attr
,
634 &iio_dev_attr_aphcal
.dev_attr
.attr
,
635 &iio_dev_attr_bphcal
.dev_attr
.attr
,
636 &iio_dev_attr_cphcal
.dev_attr
.attr
,
637 &iio_dev_attr_wdiv
.dev_attr
.attr
,
638 &iio_dev_attr_vadiv
.dev_attr
.attr
,
639 &iio_dev_attr_airms
.dev_attr
.attr
,
640 &iio_dev_attr_birms
.dev_attr
.attr
,
641 &iio_dev_attr_cirms
.dev_attr
.attr
,
642 &iio_dev_attr_avrms
.dev_attr
.attr
,
643 &iio_dev_attr_bvrms
.dev_attr
.attr
,
644 &iio_dev_attr_cvrms
.dev_attr
.attr
,
645 &iio_dev_attr_aigain
.dev_attr
.attr
,
646 &iio_dev_attr_bigain
.dev_attr
.attr
,
647 &iio_dev_attr_cigain
.dev_attr
.attr
,
648 &iio_dev_attr_avrmsgain
.dev_attr
.attr
,
649 &iio_dev_attr_bvrmsgain
.dev_attr
.attr
,
650 &iio_dev_attr_cvrmsgain
.dev_attr
.attr
,
651 &iio_dev_attr_airmsos
.dev_attr
.attr
,
652 &iio_dev_attr_birmsos
.dev_attr
.attr
,
653 &iio_dev_attr_cirmsos
.dev_attr
.attr
,
654 &iio_dev_attr_avrmsos
.dev_attr
.attr
,
655 &iio_dev_attr_bvrmsos
.dev_attr
.attr
,
656 &iio_dev_attr_cvrmsos
.dev_attr
.attr
,
660 static const struct attribute_group ade7758_attribute_group
= {
661 .attrs
= ade7758_attributes
,
664 static struct iio_chan_spec ade7758_channels
[] = {
665 IIO_CHAN(IIO_IN
, 0, 1, 0, "raw", 0, 0,
666 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
667 AD7758_WT(AD7758_PHASE_A
, AD7758_VOLTAGE
),
668 0, IIO_ST('s', 24, 32, 0), 0),
669 IIO_CHAN(IIO_CURRENT
, 0, 1, 0, "raw", 0, 0,
670 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
671 AD7758_WT(AD7758_PHASE_A
, AD7758_CURRENT
),
672 1, IIO_ST('s', 24, 32, 0), 0),
673 IIO_CHAN(IIO_POWER
, 0, 1, 0, "apparent_raw", 0, 0,
674 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
675 AD7758_WT(AD7758_PHASE_A
, AD7758_APP_PWR
),
676 2, IIO_ST('s', 24, 32, 0), 0),
677 IIO_CHAN(IIO_POWER
, 0, 1, 0, "active_raw", 0, 0,
678 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
679 AD7758_WT(AD7758_PHASE_A
, AD7758_ACT_PWR
),
680 3, IIO_ST('s', 24, 32, 0), 0),
681 IIO_CHAN(IIO_POWER
, 0, 1, 0, "reactive_raw", 0, 0,
682 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
683 AD7758_WT(AD7758_PHASE_A
, AD7758_REACT_PWR
),
684 4, IIO_ST('s', 24, 32, 0), 0),
685 IIO_CHAN(IIO_IN
, 0, 1, 0, "raw", 1, 0,
686 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
687 AD7758_WT(AD7758_PHASE_B
, AD7758_VOLTAGE
),
688 5, IIO_ST('s', 24, 32, 0), 0),
689 IIO_CHAN(IIO_CURRENT
, 0, 1, 0, "raw", 1, 0,
690 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
691 AD7758_WT(AD7758_PHASE_B
, AD7758_CURRENT
),
692 6, IIO_ST('s', 24, 32, 0), 0),
693 IIO_CHAN(IIO_POWER
, 0, 1, 0, "apparent_raw", 1, 0,
694 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
695 AD7758_WT(AD7758_PHASE_B
, AD7758_APP_PWR
),
696 7, IIO_ST('s', 24, 32, 0), 0),
697 IIO_CHAN(IIO_POWER
, 0, 1, 0, "active_raw", 1, 0,
698 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
699 AD7758_WT(AD7758_PHASE_B
, AD7758_ACT_PWR
),
700 8, IIO_ST('s', 24, 32, 0), 0),
701 IIO_CHAN(IIO_POWER
, 0, 1, 0, "reactive_raw", 1, 0,
702 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
703 AD7758_WT(AD7758_PHASE_B
, AD7758_REACT_PWR
),
704 9, IIO_ST('s', 24, 32, 0), 0),
705 IIO_CHAN(IIO_IN
, 0, 1, 0, "raw", 2, 0,
706 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
707 AD7758_WT(AD7758_PHASE_C
, AD7758_VOLTAGE
),
708 10, IIO_ST('s', 24, 32, 0), 0),
709 IIO_CHAN(IIO_CURRENT
, 0, 1, 0, "raw", 2, 0,
710 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
711 AD7758_WT(AD7758_PHASE_C
, AD7758_CURRENT
),
712 11, IIO_ST('s', 24, 32, 0), 0),
713 IIO_CHAN(IIO_POWER
, 0, 1, 0, "apparent_raw", 2, 0,
714 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
715 AD7758_WT(AD7758_PHASE_C
, AD7758_APP_PWR
),
716 12, IIO_ST('s', 24, 32, 0), 0),
717 IIO_CHAN(IIO_POWER
, 0, 1, 0, "active_raw", 2, 0,
718 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
719 AD7758_WT(AD7758_PHASE_C
, AD7758_ACT_PWR
),
720 13, IIO_ST('s', 24, 32, 0), 0),
721 IIO_CHAN(IIO_POWER
, 0, 1, 0, "reactive_raw", 2, 0,
722 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
723 AD7758_WT(AD7758_PHASE_C
, AD7758_REACT_PWR
),
724 14, IIO_ST('s', 24, 32, 0), 0),
725 IIO_CHAN_SOFT_TIMESTAMP(15),
728 static const struct iio_info ade7758_info
= {
729 .attrs
= &ade7758_attribute_group
,
730 .driver_module
= THIS_MODULE
,
733 static int __devinit
ade7758_probe(struct spi_device
*spi
)
735 int i
, ret
, regdone
= 0;
736 struct ade7758_state
*st
;
737 struct iio_dev
*indio_dev
= iio_allocate_device(sizeof(*st
));
739 if (indio_dev
== NULL
) {
744 st
= iio_priv(indio_dev
);
745 /* this is only used for removal purposes */
746 spi_set_drvdata(spi
, indio_dev
);
748 /* Allocate the comms buffers */
749 st
->rx
= kzalloc(sizeof(*st
->rx
)*ADE7758_MAX_RX
, GFP_KERNEL
);
750 if (st
->rx
== NULL
) {
754 st
->tx
= kzalloc(sizeof(*st
->tx
)*ADE7758_MAX_TX
, GFP_KERNEL
);
755 if (st
->tx
== NULL
) {
760 st
->ade7758_ring_channels
= &ade7758_channels
[0];
761 mutex_init(&st
->buf_lock
);
763 indio_dev
->name
= spi
->dev
.driver
->name
;
764 indio_dev
->dev
.parent
= &spi
->dev
;
765 indio_dev
->info
= &ade7758_info
;
766 indio_dev
->modes
= INDIO_DIRECT_MODE
;
768 for (i
= 0; i
< AD7758_NUM_WAVESRC
; i
++)
769 st
->available_scan_masks
[i
] = 1 << i
;
771 indio_dev
->available_scan_masks
= st
->available_scan_masks
;
773 ret
= ade7758_configure_ring(indio_dev
);
777 ret
= iio_device_register(indio_dev
);
779 goto error_unreg_ring_funcs
;
782 ret
= iio_ring_buffer_register_ex(indio_dev
->ring
, 0,
783 &ade7758_channels
[0],
784 ARRAY_SIZE(ade7758_channels
));
786 dev_err(&spi
->dev
, "failed to initialize the ring\n");
787 goto error_unreg_ring_funcs
;
790 /* Get the device into a sane initial state */
791 ret
= ade7758_initial_setup(indio_dev
);
793 goto error_uninitialize_ring
;
796 ret
= ade7758_probe_trigger(indio_dev
);
798 goto error_remove_trigger
;
803 error_remove_trigger
:
804 if (indio_dev
->modes
& INDIO_RING_TRIGGERED
)
805 ade7758_remove_trigger(indio_dev
);
806 error_uninitialize_ring
:
807 ade7758_uninitialize_ring(indio_dev
->ring
);
808 error_unreg_ring_funcs
:
809 ade7758_unconfigure_ring(indio_dev
);
816 iio_device_unregister(indio_dev
);
818 iio_free_device(indio_dev
);
823 static int ade7758_remove(struct spi_device
*spi
)
825 struct iio_dev
*indio_dev
= spi_get_drvdata(spi
);
826 struct ade7758_state
*st
= iio_priv(indio_dev
);
829 ret
= ade7758_stop_device(&indio_dev
->dev
);
833 ade7758_remove_trigger(indio_dev
);
834 ade7758_uninitialize_ring(indio_dev
->ring
);
835 ade7758_unconfigure_ring(indio_dev
);
838 iio_device_unregister(indio_dev
);
845 static const struct spi_device_id ade7758_id
[] = {
850 static struct spi_driver ade7758_driver
= {
853 .owner
= THIS_MODULE
,
855 .probe
= ade7758_probe
,
856 .remove
= __devexit_p(ade7758_remove
),
857 .id_table
= ade7758_id
,
860 static __init
int ade7758_init(void)
862 return spi_register_driver(&ade7758_driver
);
864 module_init(ade7758_init
);
866 static __exit
void ade7758_exit(void)
868 spi_unregister_driver(&ade7758_driver
);
870 module_exit(ade7758_exit
);
872 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
873 MODULE_DESCRIPTION("Analog Devices ADE7758 Polyphase Multifunction Energy Metering IC Driver");
874 MODULE_LICENSE("GPL v2");