Skip to content

Commit

Permalink
staging: IIO: ADC: New driver for AD7606/AD7606-6/AD7606-4
Browse files Browse the repository at this point in the history
This patch adds support for the:
AD7606/AD7606-6/AD7606-4 8/6/4-Channel Data Acquisition
system (DAS) with 16-Bit, Bipolar, Simultaneous Sampling ADC.

Changes since V1:
IIO: ADC: New driver for AD7606/AD7606-6/AD7606-4: Apply review feedback

Rename sysfs node oversampling to oversampling_ratio.
Kconfig: Add GPIOLIB dependency.
Use range in mV to better match HWMON.
Rename ad7606_check_oversampling.
Fix various comments and style.
Reorder is_visible cases.
Use new gpio_request_one/array and friends.
Drop check for SPI max_speed_hz.

Changes since V2:
IIO: ADC: New driver for AD7606/AD7606-6/AD7606-4: Apply review feedback

Documentation: specify unit
Avoid raise condition in ad7606_scan_direct()
Check return value of bus ops read_block()

Changes since V3:
IIO: ADC: New driver for AD7606/AD7606-6/AD7606-4: Add missing include file

Add linux/sched.h

Changes since V4:
IIO: ADC: New driver for AD7606/AD7606-6/AD7606-4: Fix kconfig declaration

consistently use tristate to avoid configuration mismatches

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Michael Hennerich authored and Greg Kroah-Hartman committed Feb 23, 2011
1 parent 363907a commit b9618c0
Show file tree
Hide file tree
Showing 8 changed files with 1,312 additions and 0 deletions.
25 changes: 25 additions & 0 deletions drivers/staging/iio/Documentation/sysfs-bus-iio
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,31 @@ Description:
When the internal sampling clock can only take a small
discrete set of values, this file lists those available.

What: /sys/bus/iio/devices/deviceX/range
KernelVersion: 2.6.38
Contact: linux-iio@vger.kernel.org
Description:
Hardware dependent ADC Full Scale Range in mVolt.

What: /sys/bus/iio/devices/deviceX/range_available
KernelVersion: 2.6.38
Contact: linux-iio@vger.kernel.org
Description:
Hardware dependent supported vales for ADC Full Scale Range.

What: /sys/bus/iio/devices/deviceX/oversampling_ratio
KernelVersion: 2.6.38
Contact: linux-iio@vger.kernel.org
Description:
Hardware dependent ADC oversampling. Controls the sampling ratio
of the digital filter if available.

What: /sys/bus/iio/devices/deviceX/oversampling_ratio_available
KernelVersion: 2.6.38
Contact: linux-iio@vger.kernel.org
Description:
Hardware dependent values supported by the oversampling filter.

What: /sys/bus/iio/devices/deviceX/inY_raw
What: /sys/bus/iio/devices/deviceX/inY_supply_raw
KernelVersion: 2.6.35
Expand Down
28 changes: 28 additions & 0 deletions drivers/staging/iio/adc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,34 @@ config AD7314
Say yes here to build support for Analog Devices AD7314
temperature sensors.

config AD7606
tristate "Analog Devices AD7606 ADC driver"
depends on GPIOLIB
select IIO_RING_BUFFER
select IIO_TRIGGER
select IIO_SW_RING
help
Say yes here to build support for Analog Devices:
ad7606, ad7606-6, ad7606-4 analog to digital convertors (ADC).

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

config AD7606_IFACE_PARALLEL
tristate "parallel interface support"
depends on AD7606
help
Say yes here to include parallel interface support on the AD7606
ADC driver.

config AD7606_IFACE_SPI
tristate "spi interface support"
depends on AD7606
depends on SPI
help
Say yes here to include parallel interface support on the AD7606
ADC driver.

config AD799X
tristate "Analog Devices AD799x ADC driver"
depends on I2C
Expand Down
6 changes: 6 additions & 0 deletions drivers/staging/iio/adc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ max1363-y += max1363_ring.o

obj-$(CONFIG_MAX1363) += max1363.o

ad7606-y := ad7606_core.o
ad7606-$(CONFIG_IIO_RING_BUFFER) += ad7606_ring.o
ad7606-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o
ad7606-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o
obj-$(CONFIG_AD7606) += ad7606.o

ad799x-y := ad799x_core.o
ad799x-$(CONFIG_AD799X_RING_BUFFER) += ad799x_ring.o
obj-$(CONFIG_AD799X) += ad799x.o
Expand Down
117 changes: 117 additions & 0 deletions drivers/staging/iio/adc/ad7606.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* AD7606 ADC driver
*
* Copyright 2011 Analog Devices Inc.
*
* Licensed under the GPL-2.
*/

#ifndef IIO_ADC_AD7606_H_
#define IIO_ADC_AD7606_H_

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

/**
* struct ad7606_platform_data - platform/board specifc information
* @default_os: default oversampling value {0, 2, 4, 8, 16, 32, 64}
* @default_range: default range +/-{5000, 10000} mVolt
* @gpio_convst: number of gpio connected to the CONVST pin
* @gpio_reset: gpio connected to the RESET pin, if not used set to -1
* @gpio_range: gpio connected to the RANGE pin, if not used set to -1
* @gpio_os0: gpio connected to the OS0 pin, if not used set to -1
* @gpio_os1: gpio connected to the OS1 pin, if not used set to -1
* @gpio_os2: gpio connected to the OS2 pin, if not used set to -1
* @gpio_frstdata: gpio connected to the FRSTDAT pin, if not used set to -1
* @gpio_stby: gpio connected to the STBY pin, if not used set to -1
*/

struct ad7606_platform_data {
unsigned default_os;
unsigned default_range;
unsigned gpio_convst;
unsigned gpio_reset;
unsigned gpio_range;
unsigned gpio_os0;
unsigned gpio_os1;
unsigned gpio_os2;
unsigned gpio_frstdata;
unsigned gpio_stby;
};

/**
* struct ad7606_chip_info - chip specifc information
* @name: indentification string for chip
* @bits: accuracy of the adc in bits
* @bits: output coding [s]igned or [u]nsigned
* @int_vref_mv: the internal reference voltage
* @num_channels: number of physical inputs on chip
*/

struct ad7606_chip_info {
char name[10];
u8 bits;
char sign;
u16 int_vref_mv;
unsigned num_channels;
};

/**
* struct ad7606_state - driver instance specific data
*/

struct ad7606_state {
struct iio_dev *indio_dev;
struct device *dev;
const struct ad7606_chip_info *chip_info;
struct ad7606_platform_data *pdata;
struct regulator *reg;
struct work_struct poll_work;
wait_queue_head_t wq_data_avail;
atomic_t protect_ring;
size_t d_size;
const struct ad7606_bus_ops *bops;
int irq;
unsigned id;
unsigned range;
unsigned oversampling;
bool done;
bool have_frstdata;
bool have_os;
bool have_stby;
bool have_reset;
bool have_range;
void __iomem *base_address;

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

unsigned short data[8] ____cacheline_aligned;
};

struct ad7606_bus_ops {
/* more methods added in future? */
int (*read_block)(struct device *, int, void *);
};

void ad7606_suspend(struct ad7606_state *st);
void ad7606_resume(struct ad7606_state *st);
struct ad7606_state *ad7606_probe(struct device *dev, int irq,
void __iomem *base_address, unsigned id,
const struct ad7606_bus_ops *bops);
int ad7606_remove(struct ad7606_state *st);
int ad7606_reset(struct ad7606_state *st);

enum ad7606_supported_device_ids {
ID_AD7606_8,
ID_AD7606_6,
ID_AD7606_4
};

int ad7606_scan_from_ring(struct ad7606_state *st, unsigned ch);
int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev);
void ad7606_ring_cleanup(struct iio_dev *indio_dev);
#endif /* IIO_ADC_AD7606_H_ */
Loading

0 comments on commit b9618c0

Please sign in to comment.