summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/meter/ade7758.h
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2011-05-18 13:42:07 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-19 23:14:59 (GMT)
commit8a27a023f8f66a8361c5e3d8160a690f480479ec (patch)
tree127da9e2dbde14b2d457fe7534fb590298b7d295 /drivers/staging/iio/meter/ade7758.h
parent9308bc9af00dc49919bfba58c23ae5225404064d (diff)
downloadlinux-8a27a023f8f66a8361c5e3d8160a690f480479ec.tar.xz
staging:iio:meter:ade7758: Use iio channel spec and miscellaneous other changes.
Use iio channel spec for the ring buffer channels. Add/update file comment/license headers. Use available_scan_masks to prevent that multiple channels are enabled. Remove wavefrom type attributes. (no handled directly by the scan_elements) Use SPI_MODE_1. Move ade7758_initial_setup() before ade7758_probe_trigger() to ensure the ADE7758 interrupt is disabled when the host interrupt get's enabled. Add spi_device_id. Update ring buffer setup. Some backporting needed to ensure driver builds all the way through core changes. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/meter/ade7758.h')
-rw-r--r--drivers/staging/iio/meter/ade7758.h66
1 files changed, 45 insertions, 21 deletions
diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h
index 169982b..372a9f6 100644
--- a/drivers/staging/iio/meter/ade7758.h
+++ b/drivers/staging/iio/meter/ade7758.h
@@ -1,3 +1,11 @@
+/*
+ * ADE7758 Poly Phase Multifunction Energy Metering IC driver
+ *
+ * Copyright 2010-2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
#ifndef _ADE7758_H
#define _ADE7758_H
@@ -83,12 +91,23 @@
#define ADE7758_MAX_RX 4
#define ADE7758_STARTUP_DELAY 1
-#define ADE7758_SPI_SLOW (u32)(300 * 1000)
-#define ADE7758_SPI_BURST (u32)(1000 * 1000)
-#define ADE7758_SPI_FAST (u32)(2000 * 1000)
+#define AD7758_NUM_WAVSEL 5
+#define AD7758_NUM_PHSEL 3
+#define AD7758_NUM_WAVESRC (AD7758_NUM_WAVSEL * AD7758_NUM_PHSEL)
+
+#define AD7758_PHASE_A 0
+#define AD7758_PHASE_B 1
+#define AD7758_PHASE_C 2
+#define AD7758_CURRENT 0
+#define AD7758_VOLTAGE 1
+#define AD7758_ACT_PWR 2
+#define AD7758_REACT_PWR 3
+#define AD7758_APP_PWR 4
+#define AD7758_WT(p, w) (((w) << 2) | (p))
#define DRIVER_NAME "ade7758"
+
/**
* struct ade7758_state - device instance specific data
* @us: actual spi_device
@@ -99,22 +118,29 @@
* @buf_lock: mutex to protect tx and rx
**/
struct ade7758_state {
- struct spi_device *us;
- struct iio_dev *indio_dev;
- struct iio_trigger *trig;
- u8 *tx;
- u8 *rx;
- struct mutex buf_lock;
+ struct spi_device *us;
+ struct iio_dev *indio_dev;
+ struct iio_trigger *trig;
+ u8 *tx;
+ u8 *rx;
+ struct mutex buf_lock;
+ u32 available_scan_masks[AD7758_NUM_WAVESRC];
+ struct iio_chan_spec *ade7758_ring_channels;
+ struct spi_transfer ring_xfer[4];
+ struct spi_message ring_msg;
+ /*
+ * DMA (thus cache coherency maintenance) requires the
+ * transfer buffers to live in their own cache lines.
+ */
+ unsigned char rx_buf[8] ____cacheline_aligned;
+ unsigned char tx_buf[8];
+
};
#ifdef CONFIG_IIO_RING_BUFFER
/* At the moment triggers are only used for ring buffer
* filling. This may change!
*/
-enum ade7758_scan {
- ADE7758_SCAN_WFORM,
-};
-
void ade7758_remove_trigger(struct iio_dev *indio_dev);
int ade7758_probe_trigger(struct iio_dev *indio_dev);
@@ -129,6 +155,12 @@ void ade7758_unconfigure_ring(struct iio_dev *indio_dev);
int ade7758_initialize_ring(struct iio_ring_buffer *ring);
void ade7758_uninitialize_ring(struct iio_ring_buffer *ring);
int ade7758_set_irq(struct device *dev, bool enable);
+
+int ade7758_spi_write_reg_8(struct device *dev,
+ u8 reg_address, u8 val);
+int ade7758_spi_read_reg_8(struct device *dev,
+ u8 reg_address, u8 *val);
+
#else /* CONFIG_IIO_RING_BUFFER */
static inline void ade7758_remove_trigger(struct iio_dev *indio_dev)
@@ -139,14 +171,6 @@ static inline int ade7758_probe_trigger(struct iio_dev *indio_dev)
return 0;
}
-static inline ssize_t
-ade7758_read_data_from_ring(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return 0;
-}
-
static int ade7758_configure_ring(struct iio_dev *indio_dev)
{
return 0;