Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 228159
b: refs/heads/master
c: 2b4756a
h: refs/heads/master
i:
  228157: b9e5a80
  228155: 522b9e8
  228151: eeb83c0
  228143: bc68979
  228127: 6322a36
  228095: f7e67f0
v: v3
  • Loading branch information
Michael Hennerich authored and Greg Kroah-Hartman committed Nov 29, 2010
1 parent 3681ddb commit 3581b4f
Show file tree
Hide file tree
Showing 6 changed files with 695 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b5a49481754a5cbfdc47bd701208f77c5c9010c6
refs/heads/master: 2b4756aa36909a94596752db341a0a2c8bb8c6ea
14 changes: 14 additions & 0 deletions trunk/drivers/staging/iio/adc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ config AD7476
To compile this driver as a module, choose M here: the
module will be called ad7476.

config AD7887
tristate "Analog Devices AD7887 ADC driver"
depends on SPI
select IIO_RING_BUFFER
select IIO_SW_RING
select IIO_TRIGGER
help
Say yes here to build support for Analog Devices
AD7887 SPI analog to digital convertor (ADC).
If unsure, say N (but it's safe to say "Y").

To compile this driver as a module, choose M here: the
module will be called ad7887.

config AD7745
tristate "Analog Devices AD7745, AD7746 AD7747 capacitive sensor driver"
depends on I2C
Expand Down
4 changes: 4 additions & 0 deletions trunk/drivers/staging/iio/adc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ ad7476-y := ad7476_core.o
ad7476-$(CONFIG_IIO_RING_BUFFER) += ad7476_ring.o
obj-$(CONFIG_AD7476) += ad7476.o

ad7887-y := ad7887_core.o
ad7887-$(CONFIG_IIO_RING_BUFFER) += ad7887_ring.o
obj-$(CONFIG_AD7887) += ad7887.o

obj-$(CONFIG_AD7150) += ad7150.o
obj-$(CONFIG_AD7152) += ad7152.o
obj-$(CONFIG_AD7291) += ad7291.o
Expand Down
105 changes: 105 additions & 0 deletions trunk/drivers/staging/iio/adc/ad7887.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* AD7887 SPI ADC driver
*
* Copyright 2010 Analog Devices Inc.
*
* Licensed under the GPL-2 or later.
*/
#ifndef IIO_ADC_AD7887_H_
#define IIO_ADC_AD7887_H_

#define AD7887_REF_DIS (1 << 5) /* on-chip reference disable */
#define AD7887_DUAL (1 << 4) /* dual-channel mode */
#define AD7887_CH_AIN1 (1 << 3) /* convert on channel 1, DUAL=1 */
#define AD7887_CH_AIN0 (0 << 3) /* convert on channel 0, DUAL=0,1 */
#define AD7887_PM_MODE1 (0) /* CS based shutdown */
#define AD7887_PM_MODE2 (1) /* full on */
#define AD7887_PM_MODE3 (2) /* auto shutdown after conversion */
#define AD7887_PM_MODE4 (3) /* standby mode */

enum ad7887_channels {
AD7887_CH0,
AD7887_CH0_CH1,
AD7887_CH1,
};

#define RES_MASK(bits) ((1 << (bits)) - 1) /* TODO: move this into a common header */

/*
* TODO: struct ad7887_platform_data needs to go into include/linux/iio
*/

struct ad7887_platform_data {
/* External Vref voltage applied */
u16 vref_mv;
/*
* AD7887:
* In single channel mode en_dual = flase, AIN1/Vref pins assumes its
* Vref function. In dual channel mode en_dual = true, AIN1 becomes the
* second input channel, and Vref is internally connected to Vdd.
*/
bool en_dual;
/*
* AD7887:
* use_onchip_ref = true, the Vref is internally connected to the 2.500V
* Voltage reference. If use_onchip_ref = false, the reference voltage
* is supplied by AIN1/Vref
*/
bool use_onchip_ref;
};

struct ad7887_chip_info {
u8 bits; /* number of ADC bits */
u8 storagebits; /* number of bits read from the ADC */
u8 left_shift; /* number of bits the sample must be shifted */
char sign; /* [s]igned or [u]nsigned */
u16 int_vref_mv; /* internal reference voltage */
};

struct ad7887_state {
struct iio_dev *indio_dev;
struct spi_device *spi;
const struct ad7887_chip_info *chip_info;
struct regulator *reg;
struct work_struct poll_work;
atomic_t protect_ring;
u16 int_vref_mv;
bool en_dual;
struct spi_transfer xfer[4];
struct spi_message msg[3];
struct spi_message *ring_msg;
unsigned char tx_cmd_buf[8];

/*
* DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines.
*/

unsigned char data[4] ____cacheline_aligned;
};

enum ad7887_supported_device_ids {
ID_AD7887
};

#ifdef CONFIG_IIO_RING_BUFFER
int ad7887_scan_from_ring(struct ad7887_state *st, long mask);
int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev);
void ad7887_ring_cleanup(struct iio_dev *indio_dev);
#else /* CONFIG_IIO_RING_BUFFER */
static inline int ad7887_scan_from_ring(struct ad7887_state *st, long mask)
{
return 0;
}

static inline int
ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev)
{
return 0;
}

static inline void ad7887_ring_cleanup(struct iio_dev *indio_dev)
{
}
#endif /* CONFIG_IIO_RING_BUFFER */
#endif /* IIO_ADC_AD7887_H_ */
Loading

0 comments on commit 3581b4f

Please sign in to comment.