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>
20 #include <linux/module.h>
24 #include "../ring_generic.h"
28 int ade7758_spi_write_reg_8(struct device
*dev
,
33 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
34 struct ade7758_state
*st
= iio_priv(indio_dev
);
36 mutex_lock(&st
->buf_lock
);
37 st
->tx
[0] = ADE7758_WRITE_REG(reg_address
);
40 ret
= spi_write(st
->us
, st
->tx
, 2);
41 mutex_unlock(&st
->buf_lock
);
46 static int ade7758_spi_write_reg_16(struct device
*dev
,
51 struct spi_message msg
;
52 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
53 struct ade7758_state
*st
= iio_priv(indio_dev
);
54 struct spi_transfer xfers
[] = {
62 mutex_lock(&st
->buf_lock
);
63 st
->tx
[0] = ADE7758_WRITE_REG(reg_address
);
64 st
->tx
[1] = (value
>> 8) & 0xFF;
65 st
->tx
[2] = value
& 0xFF;
67 spi_message_init(&msg
);
68 spi_message_add_tail(xfers
, &msg
);
69 ret
= spi_sync(st
->us
, &msg
);
70 mutex_unlock(&st
->buf_lock
);
75 static int ade7758_spi_write_reg_24(struct device
*dev
,
80 struct spi_message msg
;
81 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
82 struct ade7758_state
*st
= iio_priv(indio_dev
);
83 struct spi_transfer xfers
[] = {
91 mutex_lock(&st
->buf_lock
);
92 st
->tx
[0] = ADE7758_WRITE_REG(reg_address
);
93 st
->tx
[1] = (value
>> 16) & 0xFF;
94 st
->tx
[2] = (value
>> 8) & 0xFF;
95 st
->tx
[3] = value
& 0xFF;
97 spi_message_init(&msg
);
98 spi_message_add_tail(xfers
, &msg
);
99 ret
= spi_sync(st
->us
, &msg
);
100 mutex_unlock(&st
->buf_lock
);
105 int ade7758_spi_read_reg_8(struct device
*dev
,
109 struct spi_message msg
;
110 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
111 struct ade7758_state
*st
= iio_priv(indio_dev
);
113 struct spi_transfer xfers
[] = {
121 .tx_buf
= &st
->tx
[1],
128 mutex_lock(&st
->buf_lock
);
129 st
->tx
[0] = ADE7758_READ_REG(reg_address
);
132 spi_message_init(&msg
);
133 spi_message_add_tail(&xfers
[0], &msg
);
134 spi_message_add_tail(&xfers
[1], &msg
);
135 ret
= spi_sync(st
->us
, &msg
);
137 dev_err(&st
->us
->dev
, "problem when reading 8 bit register 0x%02X",
144 mutex_unlock(&st
->buf_lock
);
148 static int ade7758_spi_read_reg_16(struct device
*dev
,
152 struct spi_message msg
;
153 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
154 struct ade7758_state
*st
= iio_priv(indio_dev
);
156 struct spi_transfer xfers
[] = {
164 .tx_buf
= &st
->tx
[1],
172 mutex_lock(&st
->buf_lock
);
173 st
->tx
[0] = ADE7758_READ_REG(reg_address
);
177 spi_message_init(&msg
);
178 spi_message_add_tail(&xfers
[0], &msg
);
179 spi_message_add_tail(&xfers
[1], &msg
);
180 ret
= spi_sync(st
->us
, &msg
);
182 dev_err(&st
->us
->dev
, "problem when reading 16 bit register 0x%02X",
187 *val
= (st
->rx
[0] << 8) | st
->rx
[1];
190 mutex_unlock(&st
->buf_lock
);
194 static int ade7758_spi_read_reg_24(struct device
*dev
,
198 struct spi_message msg
;
199 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
200 struct ade7758_state
*st
= iio_priv(indio_dev
);
202 struct spi_transfer xfers
[] = {
210 .tx_buf
= &st
->tx
[1],
217 mutex_lock(&st
->buf_lock
);
218 st
->tx
[0] = ADE7758_READ_REG(reg_address
);
223 spi_message_init(&msg
);
224 spi_message_add_tail(&xfers
[0], &msg
);
225 spi_message_add_tail(&xfers
[1], &msg
);
226 ret
= spi_sync(st
->us
, &msg
);
228 dev_err(&st
->us
->dev
, "problem when reading 24 bit register 0x%02X",
232 *val
= (st
->rx
[0] << 16) | (st
->rx
[1] << 8) | st
->rx
[2];
235 mutex_unlock(&st
->buf_lock
);
239 static ssize_t
ade7758_read_8bit(struct device
*dev
,
240 struct device_attribute
*attr
,
245 struct iio_dev_attr
*this_attr
= to_iio_dev_attr(attr
);
247 ret
= ade7758_spi_read_reg_8(dev
, this_attr
->address
, &val
);
251 return sprintf(buf
, "%u\n", val
);
254 static ssize_t
ade7758_read_16bit(struct device
*dev
,
255 struct device_attribute
*attr
,
260 struct iio_dev_attr
*this_attr
= to_iio_dev_attr(attr
);
262 ret
= ade7758_spi_read_reg_16(dev
, this_attr
->address
, &val
);
266 return sprintf(buf
, "%u\n", val
);
269 static ssize_t
ade7758_read_24bit(struct device
*dev
,
270 struct device_attribute
*attr
,
275 struct iio_dev_attr
*this_attr
= to_iio_dev_attr(attr
);
277 ret
= ade7758_spi_read_reg_24(dev
, this_attr
->address
, &val
);
281 return sprintf(buf
, "%u\n", val
& 0xFFFFFF);
284 static ssize_t
ade7758_write_8bit(struct device
*dev
,
285 struct device_attribute
*attr
,
289 struct iio_dev_attr
*this_attr
= to_iio_dev_attr(attr
);
293 ret
= strict_strtol(buf
, 10, &val
);
296 ret
= ade7758_spi_write_reg_8(dev
, this_attr
->address
, val
);
299 return ret
? ret
: len
;
302 static ssize_t
ade7758_write_16bit(struct device
*dev
,
303 struct device_attribute
*attr
,
307 struct iio_dev_attr
*this_attr
= to_iio_dev_attr(attr
);
311 ret
= strict_strtol(buf
, 10, &val
);
314 ret
= ade7758_spi_write_reg_16(dev
, this_attr
->address
, val
);
317 return ret
? ret
: len
;
320 static int ade7758_reset(struct device
*dev
)
324 ade7758_spi_read_reg_8(dev
,
327 val
|= 1 << 6; /* Software Chip Reset */
328 ret
= ade7758_spi_write_reg_8(dev
,
335 static ssize_t
ade7758_write_reset(struct device
*dev
,
336 struct device_attribute
*attr
,
337 const char *buf
, size_t len
)
345 return ade7758_reset(dev
);
350 static IIO_DEV_ATTR_VPEAK(S_IWUSR
| S_IRUGO
,
354 static IIO_DEV_ATTR_IPEAK(S_IWUSR
| S_IRUGO
,
358 static IIO_DEV_ATTR_APHCAL(S_IWUSR
| S_IRUGO
,
362 static IIO_DEV_ATTR_BPHCAL(S_IWUSR
| S_IRUGO
,
366 static IIO_DEV_ATTR_CPHCAL(S_IWUSR
| S_IRUGO
,
370 static IIO_DEV_ATTR_WDIV(S_IWUSR
| S_IRUGO
,
374 static IIO_DEV_ATTR_VADIV(S_IWUSR
| S_IRUGO
,
378 static IIO_DEV_ATTR_AIRMS(S_IRUGO
,
382 static IIO_DEV_ATTR_BIRMS(S_IRUGO
,
386 static IIO_DEV_ATTR_CIRMS(S_IRUGO
,
390 static IIO_DEV_ATTR_AVRMS(S_IRUGO
,
394 static IIO_DEV_ATTR_BVRMS(S_IRUGO
,
398 static IIO_DEV_ATTR_CVRMS(S_IRUGO
,
402 static IIO_DEV_ATTR_AIRMSOS(S_IWUSR
| S_IRUGO
,
406 static IIO_DEV_ATTR_BIRMSOS(S_IWUSR
| S_IRUGO
,
410 static IIO_DEV_ATTR_CIRMSOS(S_IWUSR
| S_IRUGO
,
414 static IIO_DEV_ATTR_AVRMSOS(S_IWUSR
| S_IRUGO
,
418 static IIO_DEV_ATTR_BVRMSOS(S_IWUSR
| S_IRUGO
,
422 static IIO_DEV_ATTR_CVRMSOS(S_IWUSR
| S_IRUGO
,
426 static IIO_DEV_ATTR_AIGAIN(S_IWUSR
| S_IRUGO
,
430 static IIO_DEV_ATTR_BIGAIN(S_IWUSR
| S_IRUGO
,
434 static IIO_DEV_ATTR_CIGAIN(S_IWUSR
| S_IRUGO
,
438 static IIO_DEV_ATTR_AVRMSGAIN(S_IWUSR
| S_IRUGO
,
442 static IIO_DEV_ATTR_BVRMSGAIN(S_IWUSR
| S_IRUGO
,
446 static IIO_DEV_ATTR_CVRMSGAIN(S_IWUSR
| S_IRUGO
,
451 int ade7758_set_irq(struct device
*dev
, bool enable
)
455 ret
= ade7758_spi_read_reg_24(dev
, ADE7758_MASK
, &irqen
);
460 irqen
|= 1 << 16; /* Enables an interrupt when a data is
461 present in the waveform register */
465 ret
= ade7758_spi_write_reg_24(dev
, ADE7758_MASK
, irqen
);
473 /* Power down the device */
474 static int ade7758_stop_device(struct device
*dev
)
478 ade7758_spi_read_reg_8(dev
,
481 val
|= 7 << 3; /* ADE7758 powered down */
482 ret
= ade7758_spi_write_reg_8(dev
,
489 static int ade7758_initial_setup(struct iio_dev
*indio_dev
)
491 struct ade7758_state
*st
= iio_priv(indio_dev
);
492 struct device
*dev
= &indio_dev
->dev
;
495 /* use low spi speed for init */
496 st
->us
->mode
= SPI_MODE_1
;
500 ret
= ade7758_set_irq(dev
, false);
502 dev_err(dev
, "disable irq failed");
507 msleep(ADE7758_STARTUP_DELAY
);
513 static ssize_t
ade7758_read_frequency(struct device
*dev
,
514 struct device_attribute
*attr
,
520 ret
= ade7758_spi_read_reg_8(dev
,
527 sps
= 26040 / (1 << t
);
529 len
= sprintf(buf
, "%d SPS\n", sps
);
533 static ssize_t
ade7758_write_frequency(struct device
*dev
,
534 struct device_attribute
*attr
,
538 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
543 ret
= strict_strtol(buf
, 10, &val
);
547 mutex_lock(&indio_dev
->mlock
);
567 ret
= ade7758_spi_read_reg_8(dev
,
576 ret
= ade7758_spi_write_reg_8(dev
,
581 mutex_unlock(&indio_dev
->mlock
);
583 return ret
? ret
: len
;
586 static IIO_DEV_ATTR_TEMP_RAW(ade7758_read_8bit
);
587 static IIO_CONST_ATTR(temp_offset
, "129 C");
588 static IIO_CONST_ATTR(temp_scale
, "4 C");
590 static IIO_DEV_ATTR_AWATTHR(ade7758_read_16bit
,
592 static IIO_DEV_ATTR_BWATTHR(ade7758_read_16bit
,
594 static IIO_DEV_ATTR_CWATTHR(ade7758_read_16bit
,
596 static IIO_DEV_ATTR_AVARHR(ade7758_read_16bit
,
598 static IIO_DEV_ATTR_BVARHR(ade7758_read_16bit
,
600 static IIO_DEV_ATTR_CVARHR(ade7758_read_16bit
,
602 static IIO_DEV_ATTR_AVAHR(ade7758_read_16bit
,
604 static IIO_DEV_ATTR_BVAHR(ade7758_read_16bit
,
606 static IIO_DEV_ATTR_CVAHR(ade7758_read_16bit
,
609 static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR
| S_IRUGO
,
610 ade7758_read_frequency
,
611 ade7758_write_frequency
);
613 static IIO_DEV_ATTR_RESET(ade7758_write_reset
);
615 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26040 13020 6510 3255");
617 static struct attribute
*ade7758_attributes
[] = {
618 &iio_dev_attr_temp_raw
.dev_attr
.attr
,
619 &iio_const_attr_temp_offset
.dev_attr
.attr
,
620 &iio_const_attr_temp_scale
.dev_attr
.attr
,
621 &iio_dev_attr_sampling_frequency
.dev_attr
.attr
,
622 &iio_const_attr_sampling_frequency_available
.dev_attr
.attr
,
623 &iio_dev_attr_reset
.dev_attr
.attr
,
624 &iio_dev_attr_awatthr
.dev_attr
.attr
,
625 &iio_dev_attr_bwatthr
.dev_attr
.attr
,
626 &iio_dev_attr_cwatthr
.dev_attr
.attr
,
627 &iio_dev_attr_avarhr
.dev_attr
.attr
,
628 &iio_dev_attr_bvarhr
.dev_attr
.attr
,
629 &iio_dev_attr_cvarhr
.dev_attr
.attr
,
630 &iio_dev_attr_avahr
.dev_attr
.attr
,
631 &iio_dev_attr_bvahr
.dev_attr
.attr
,
632 &iio_dev_attr_cvahr
.dev_attr
.attr
,
633 &iio_dev_attr_vpeak
.dev_attr
.attr
,
634 &iio_dev_attr_ipeak
.dev_attr
.attr
,
635 &iio_dev_attr_aphcal
.dev_attr
.attr
,
636 &iio_dev_attr_bphcal
.dev_attr
.attr
,
637 &iio_dev_attr_cphcal
.dev_attr
.attr
,
638 &iio_dev_attr_wdiv
.dev_attr
.attr
,
639 &iio_dev_attr_vadiv
.dev_attr
.attr
,
640 &iio_dev_attr_airms
.dev_attr
.attr
,
641 &iio_dev_attr_birms
.dev_attr
.attr
,
642 &iio_dev_attr_cirms
.dev_attr
.attr
,
643 &iio_dev_attr_avrms
.dev_attr
.attr
,
644 &iio_dev_attr_bvrms
.dev_attr
.attr
,
645 &iio_dev_attr_cvrms
.dev_attr
.attr
,
646 &iio_dev_attr_aigain
.dev_attr
.attr
,
647 &iio_dev_attr_bigain
.dev_attr
.attr
,
648 &iio_dev_attr_cigain
.dev_attr
.attr
,
649 &iio_dev_attr_avrmsgain
.dev_attr
.attr
,
650 &iio_dev_attr_bvrmsgain
.dev_attr
.attr
,
651 &iio_dev_attr_cvrmsgain
.dev_attr
.attr
,
652 &iio_dev_attr_airmsos
.dev_attr
.attr
,
653 &iio_dev_attr_birmsos
.dev_attr
.attr
,
654 &iio_dev_attr_cirmsos
.dev_attr
.attr
,
655 &iio_dev_attr_avrmsos
.dev_attr
.attr
,
656 &iio_dev_attr_bvrmsos
.dev_attr
.attr
,
657 &iio_dev_attr_cvrmsos
.dev_attr
.attr
,
661 static const struct attribute_group ade7758_attribute_group
= {
662 .attrs
= ade7758_attributes
,
665 static struct iio_chan_spec ade7758_channels
[] = {
666 IIO_CHAN(IIO_IN
, 0, 1, 0, "raw", 0, 0,
667 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
668 AD7758_WT(AD7758_PHASE_A
, AD7758_VOLTAGE
),
669 0, IIO_ST('s', 24, 32, 0), 0),
670 IIO_CHAN(IIO_CURRENT
, 0, 1, 0, "raw", 0, 0,
671 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
672 AD7758_WT(AD7758_PHASE_A
, AD7758_CURRENT
),
673 1, IIO_ST('s', 24, 32, 0), 0),
674 IIO_CHAN(IIO_POWER
, 0, 1, 0, "apparent_raw", 0, 0,
675 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
676 AD7758_WT(AD7758_PHASE_A
, AD7758_APP_PWR
),
677 2, IIO_ST('s', 24, 32, 0), 0),
678 IIO_CHAN(IIO_POWER
, 0, 1, 0, "active_raw", 0, 0,
679 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
680 AD7758_WT(AD7758_PHASE_A
, AD7758_ACT_PWR
),
681 3, IIO_ST('s', 24, 32, 0), 0),
682 IIO_CHAN(IIO_POWER
, 0, 1, 0, "reactive_raw", 0, 0,
683 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
684 AD7758_WT(AD7758_PHASE_A
, AD7758_REACT_PWR
),
685 4, IIO_ST('s', 24, 32, 0), 0),
686 IIO_CHAN(IIO_IN
, 0, 1, 0, "raw", 1, 0,
687 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
688 AD7758_WT(AD7758_PHASE_B
, AD7758_VOLTAGE
),
689 5, IIO_ST('s', 24, 32, 0), 0),
690 IIO_CHAN(IIO_CURRENT
, 0, 1, 0, "raw", 1, 0,
691 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
692 AD7758_WT(AD7758_PHASE_B
, AD7758_CURRENT
),
693 6, IIO_ST('s', 24, 32, 0), 0),
694 IIO_CHAN(IIO_POWER
, 0, 1, 0, "apparent_raw", 1, 0,
695 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
696 AD7758_WT(AD7758_PHASE_B
, AD7758_APP_PWR
),
697 7, IIO_ST('s', 24, 32, 0), 0),
698 IIO_CHAN(IIO_POWER
, 0, 1, 0, "active_raw", 1, 0,
699 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
700 AD7758_WT(AD7758_PHASE_B
, AD7758_ACT_PWR
),
701 8, IIO_ST('s', 24, 32, 0), 0),
702 IIO_CHAN(IIO_POWER
, 0, 1, 0, "reactive_raw", 1, 0,
703 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
704 AD7758_WT(AD7758_PHASE_B
, AD7758_REACT_PWR
),
705 9, IIO_ST('s', 24, 32, 0), 0),
706 IIO_CHAN(IIO_IN
, 0, 1, 0, "raw", 2, 0,
707 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
708 AD7758_WT(AD7758_PHASE_C
, AD7758_VOLTAGE
),
709 10, IIO_ST('s', 24, 32, 0), 0),
710 IIO_CHAN(IIO_CURRENT
, 0, 1, 0, "raw", 2, 0,
711 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
712 AD7758_WT(AD7758_PHASE_C
, AD7758_CURRENT
),
713 11, IIO_ST('s', 24, 32, 0), 0),
714 IIO_CHAN(IIO_POWER
, 0, 1, 0, "apparent_raw", 2, 0,
715 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
716 AD7758_WT(AD7758_PHASE_C
, AD7758_APP_PWR
),
717 12, IIO_ST('s', 24, 32, 0), 0),
718 IIO_CHAN(IIO_POWER
, 0, 1, 0, "active_raw", 2, 0,
719 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
720 AD7758_WT(AD7758_PHASE_C
, AD7758_ACT_PWR
),
721 13, IIO_ST('s', 24, 32, 0), 0),
722 IIO_CHAN(IIO_POWER
, 0, 1, 0, "reactive_raw", 2, 0,
723 (1 << IIO_CHAN_INFO_SCALE_SHARED
),
724 AD7758_WT(AD7758_PHASE_C
, AD7758_REACT_PWR
),
725 14, IIO_ST('s', 24, 32, 0), 0),
726 IIO_CHAN_SOFT_TIMESTAMP(15),
729 static const struct iio_info ade7758_info
= {
730 .attrs
= &ade7758_attribute_group
,
731 .driver_module
= THIS_MODULE
,
734 static int __devinit
ade7758_probe(struct spi_device
*spi
)
736 int i
, ret
, regdone
= 0;
737 struct ade7758_state
*st
;
738 struct iio_dev
*indio_dev
= iio_allocate_device(sizeof(*st
));
740 if (indio_dev
== NULL
) {
745 st
= iio_priv(indio_dev
);
746 /* this is only used for removal purposes */
747 spi_set_drvdata(spi
, indio_dev
);
749 /* Allocate the comms buffers */
750 st
->rx
= kzalloc(sizeof(*st
->rx
)*ADE7758_MAX_RX
, GFP_KERNEL
);
751 if (st
->rx
== NULL
) {
755 st
->tx
= kzalloc(sizeof(*st
->tx
)*ADE7758_MAX_TX
, GFP_KERNEL
);
756 if (st
->tx
== NULL
) {
761 st
->ade7758_ring_channels
= &ade7758_channels
[0];
762 mutex_init(&st
->buf_lock
);
764 indio_dev
->name
= spi
->dev
.driver
->name
;
765 indio_dev
->dev
.parent
= &spi
->dev
;
766 indio_dev
->info
= &ade7758_info
;
767 indio_dev
->modes
= INDIO_DIRECT_MODE
;
769 for (i
= 0; i
< AD7758_NUM_WAVESRC
; i
++)
770 st
->available_scan_masks
[i
] = 1 << i
;
772 indio_dev
->available_scan_masks
= st
->available_scan_masks
;
774 ret
= ade7758_configure_ring(indio_dev
);
778 ret
= iio_device_register(indio_dev
);
780 goto error_unreg_ring_funcs
;
783 ret
= iio_ring_buffer_register_ex(indio_dev
, 0,
784 &ade7758_channels
[0],
785 ARRAY_SIZE(ade7758_channels
));
787 dev_err(&spi
->dev
, "failed to initialize the ring\n");
788 goto error_unreg_ring_funcs
;
791 /* Get the device into a sane initial state */
792 ret
= ade7758_initial_setup(indio_dev
);
794 goto error_uninitialize_ring
;
797 ret
= ade7758_probe_trigger(indio_dev
);
799 goto error_remove_trigger
;
804 error_remove_trigger
:
805 if (indio_dev
->modes
& INDIO_RING_TRIGGERED
)
806 ade7758_remove_trigger(indio_dev
);
807 error_uninitialize_ring
:
808 ade7758_uninitialize_ring(indio_dev
);
809 error_unreg_ring_funcs
:
810 ade7758_unconfigure_ring(indio_dev
);
817 iio_device_unregister(indio_dev
);
819 iio_free_device(indio_dev
);
824 static int ade7758_remove(struct spi_device
*spi
)
826 struct iio_dev
*indio_dev
= spi_get_drvdata(spi
);
827 struct ade7758_state
*st
= iio_priv(indio_dev
);
830 ret
= ade7758_stop_device(&indio_dev
->dev
);
834 ade7758_remove_trigger(indio_dev
);
835 ade7758_uninitialize_ring(indio_dev
);
836 ade7758_unconfigure_ring(indio_dev
);
839 iio_device_unregister(indio_dev
);
846 static const struct spi_device_id ade7758_id
[] = {
851 static struct spi_driver ade7758_driver
= {
854 .owner
= THIS_MODULE
,
856 .probe
= ade7758_probe
,
857 .remove
= __devexit_p(ade7758_remove
),
858 .id_table
= ade7758_id
,
861 static __init
int ade7758_init(void)
863 return spi_register_driver(&ade7758_driver
);
865 module_init(ade7758_init
);
867 static __exit
void ade7758_exit(void)
869 spi_unregister_driver(&ade7758_driver
);
871 module_exit(ade7758_exit
);
873 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
874 MODULE_DESCRIPTION("Analog Devices ADE7758 Polyphase Multifunction Energy Metering IC Driver");
875 MODULE_LICENSE("GPL v2");