Skip to content

Commit

Permalink
Staging: IIO: DAC: AD5624R: Update to IIO ABI
Browse files Browse the repository at this point in the history
This driver did not conform with the IIO ABI for such devices.
Also the sysfs files that this driver adds were not complete and
partially un-documented.

Update and document ABI
Change License notice, stick to GPL-v2.
Fix indention style
Add option to specify external reference voltage via the regulator framework.
Add mandatory name attribute
Add mandatory out_scale attribute

Changes since V1:
Refine outY_powerdown_mode description
Remove bonus white line

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 Mar 9, 2011
1 parent 1f0e427 commit 14f88f1
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 111 deletions.
32 changes: 32 additions & 0 deletions drivers/staging/iio/Documentation/sysfs-bus-iio
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,38 @@ Description:
where a single output sets the value for multiple channels
simultaneously.

What: /sys/bus/iio/devices/deviceX/outY_powerdown_mode
What: /sys/bus/iio/devices/deviceX/out_powerdown_mode
KernelVersion: 2.6.38
Contact: linux-iio@vger.kernel.org
Description:
Specifies the output powerdown mode.
DAC output stage is disconnected from the amplifier and
1kohm_to_gnd: connected to ground via an 1kOhm resistor
100kohm_to_gnd: connected to ground via an 100kOhm resistor
three_state: left floating
For a list of available output power down options read
outX_powerdown_mode_available. If Y is not present the
mode is shared across all outputs.

What: /sys/bus/iio/devices/deviceX/outY_powerdown_mode_available
What: /sys/bus/iio/devices/deviceX/out_powerdown_mode_available
KernelVersion: 2.6.38
Contact: linux-iio@vger.kernel.org
Description:
Lists all available output power down modes.
If Y is not present the mode is shared across all outputs.

What: /sys/bus/iio/devices/deviceX/outY_powerdown
What: /sys/bus/iio/devices/deviceX/out_powerdown
KernelVersion: 2.6.38
Contact: linux-iio@vger.kernel.org
Description:
Writing 1 causes output Y to enter the power down mode specified
by the corresponding outY_powerdown_mode. Clearing returns to
normal operation. Y may be suppressed if all outputs are
controlled together.

What: /sys/bus/iio/devices/deviceX/deviceX:eventY
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Expand Down
89 changes: 74 additions & 15 deletions drivers/staging/iio/dac/ad5624r.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,80 @@
/*
* AD5624R SPI DAC driver
*
* Copyright 2010-2011 Analog Devices Inc.
*
* Licensed under the GPL-2.
*/
#ifndef SPI_AD5624R_H_
#define SPI_AD5624R_H_

#define AD5624R_DAC_CHANNELS 4
#define AD5624R_DAC_CHANNELS 4

#define AD5624R_ADDR_DAC0 0x0
#define AD5624R_ADDR_DAC1 0x1
#define AD5624R_ADDR_DAC2 0x2
#define AD5624R_ADDR_DAC3 0x3
#define AD5624R_ADDR_ALL_DAC 0x7
#define AD5624R_ADDR_DAC0 0x0
#define AD5624R_ADDR_DAC1 0x1
#define AD5624R_ADDR_DAC2 0x2
#define AD5624R_ADDR_DAC3 0x3
#define AD5624R_ADDR_ALL_DAC 0x7

#define AD5624R_CMD_WRITE_INPUT_N 0x0
#define AD5624R_CMD_UPDATE_DAC_N 0x1
#define AD5624R_CMD_WRITE_INPUT_N_UPDATE_ALL 0x2
#define AD5624R_CMD_WRITE_INPUT_N_UPDATE_N 0x3
#define AD5624R_CMD_POWERDOWN_DAC 0x4
#define AD5624R_CMD_RESET 0x5
#define AD5624R_CMD_LDAC_SETUP 0x6
#define AD5624R_CMD_INTERNAL_REFER_SETUP 0x7
#define AD5624R_CMD_WRITE_INPUT_N 0x0
#define AD5624R_CMD_UPDATE_DAC_N 0x1
#define AD5624R_CMD_WRITE_INPUT_N_UPDATE_ALL 0x2
#define AD5624R_CMD_WRITE_INPUT_N_UPDATE_N 0x3
#define AD5624R_CMD_POWERDOWN_DAC 0x4
#define AD5624R_CMD_RESET 0x5
#define AD5624R_CMD_LDAC_SETUP 0x6
#define AD5624R_CMD_INTERNAL_REFER_SETUP 0x7

#endif
#define AD5624R_LDAC_PWRDN_NONE 0x0
#define AD5624R_LDAC_PWRDN_1K 0x1
#define AD5624R_LDAC_PWRDN_100K 0x2
#define AD5624R_LDAC_PWRDN_3STATE 0x3

/**
* struct ad5624r_chip_info - chip specific information
* @bits: accuracy of the DAC in bits
* @int_vref_mv: AD5620/40/60: the internal reference voltage
*/

struct ad5624r_chip_info {
u8 bits;
u16 int_vref_mv;
};

/**
* struct ad5446_state - driver instance specific data
* @indio_dev: the industrial I/O device
* @us: spi_device
* @chip_info: chip model specific constants, available modes etc
* @reg: supply regulator
* @vref_mv: actual reference voltage used
* @pwr_down_mask power down mask
* @pwr_down_mode current power down mode
*/

struct ad5624r_state {
struct iio_dev *indio_dev;
struct spi_device *us;
const struct ad5624r_chip_info *chip_info;
struct regulator *reg;
unsigned short vref_mv;
unsigned pwr_down_mask;
unsigned pwr_down_mode;
};

/**
* ad5624r_supported_device_ids:
* The AD5624/44/64 parts are available in different
* fixed internal reference voltage options.
*/

enum ad5624r_supported_device_ids {
ID_AD5624R3,
ID_AD5644R3,
ID_AD5664R3,
ID_AD5624R5,
ID_AD5644R5,
ID_AD5664R5,
};

#endif /* SPI_AD5624R_H_ */
Loading

0 comments on commit 14f88f1

Please sign in to comment.