Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 289151
b: refs/heads/master
c: 83c169d
h: refs/heads/master
i:
  289149: b992bb2
  289147: 95328a4
  289143: ef00561
  289135: 34c4f73
  289119: f55b159
  289087: 0365702
  289023: 4a6edb2
v: v3
  • Loading branch information
Lars-Peter Clausen authored and Greg Kroah-Hartman committed Feb 24, 2012
1 parent c8e3116 commit 4b7db50
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1d0d879405db0a845584a1e7a15b39de1f4f7e53
refs/heads/master: 83c169d57e8e7496737ced86b93235990864044b
61 changes: 34 additions & 27 deletions trunk/drivers/staging/iio/dac/ad5064.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#include "../sysfs.h"
#include "dac.h"

#define AD5064_DAC_CHANNELS 4
#define AD5064_MAX_DAC_CHANNELS 4
#define AD5064_MAX_VREFS 4

#define AD5064_ADDR(x) ((x) << 20)
#define AD5064_CMD(x) ((x) << 24)
Expand All @@ -46,11 +47,13 @@
* struct ad5064_chip_info - chip specific information
* @shared_vref: whether the vref supply is shared between channels
* @channel: channel specification
*/
* @num_channels: number of channels
*/

struct ad5064_chip_info {
bool shared_vref;
struct iio_chan_spec channel[AD5064_DAC_CHANNELS];
const struct iio_chan_spec *channels;
unsigned int num_channels;
};

/**
Expand All @@ -67,10 +70,10 @@ struct ad5064_chip_info {
struct ad5064_state {
struct spi_device *spi;
const struct ad5064_chip_info *chip_info;
struct regulator_bulk_data vref_reg[AD5064_DAC_CHANNELS];
bool pwr_down[AD5064_DAC_CHANNELS];
u8 pwr_down_mode[AD5064_DAC_CHANNELS];
unsigned int dac_cache[AD5064_DAC_CHANNELS];
struct regulator_bulk_data vref_reg[AD5064_MAX_VREFS];
bool pwr_down[AD5064_MAX_DAC_CHANNELS];
u8 pwr_down_mode[AD5064_MAX_DAC_CHANNELS];
unsigned int dac_cache[AD5064_MAX_DAC_CHANNELS];

/*
* DMA (thus cache coherency maintenance) requires the
Expand Down Expand Up @@ -280,40 +283,44 @@ static struct iio_chan_spec_ext_info ad5064_ext_info[] = {
.ext_info = ad5064_ext_info, \
}

#define DECLARE_AD5064_CHANNELS(name, bits) \
const struct iio_chan_spec name[] = { \
AD5064_CHANNEL(0, bits), \
AD5064_CHANNEL(1, bits), \
AD5064_CHANNEL(2, bits), \
AD5064_CHANNEL(3, bits), \
}

static DECLARE_AD5064_CHANNELS(ad5024_channels, 12);
static DECLARE_AD5064_CHANNELS(ad5044_channels, 14);
static DECLARE_AD5064_CHANNELS(ad5064_channels, 16);

static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
[ID_AD5024] = {
.shared_vref = false,
.channel[0] = AD5064_CHANNEL(0, 12),
.channel[1] = AD5064_CHANNEL(1, 12),
.channel[2] = AD5064_CHANNEL(2, 12),
.channel[3] = AD5064_CHANNEL(3, 12),
.channels = ad5024_channels,
.num_channels = 4,
},
[ID_AD5044] = {
.shared_vref = false,
.channel[0] = AD5064_CHANNEL(0, 14),
.channel[1] = AD5064_CHANNEL(1, 14),
.channel[2] = AD5064_CHANNEL(2, 14),
.channel[3] = AD5064_CHANNEL(3, 14),
.channels = ad5044_channels,
.num_channels = 4,
},
[ID_AD5064] = {
.shared_vref = false,
.channel[0] = AD5064_CHANNEL(0, 16),
.channel[1] = AD5064_CHANNEL(1, 16),
.channel[2] = AD5064_CHANNEL(2, 16),
.channel[3] = AD5064_CHANNEL(3, 16),
.channels = ad5064_channels,
.num_channels = 4,
},
[ID_AD5064_1] = {
.shared_vref = true,
.channel[0] = AD5064_CHANNEL(0, 16),
.channel[1] = AD5064_CHANNEL(1, 16),
.channel[2] = AD5064_CHANNEL(2, 16),
.channel[3] = AD5064_CHANNEL(3, 16),
.channels = ad5064_channels,
.num_channels = 4,
},
};

static inline unsigned int ad5064_num_vref(struct ad5064_state *st)
{
return st->chip_info->shared_vref ? 1 : AD5064_DAC_CHANNELS;
return st->chip_info->shared_vref ? 1 : st->chip_info->num_channels;
}

static const char * const ad5064_vref_names[] = {
Expand Down Expand Up @@ -359,7 +366,7 @@ static int __devinit ad5064_probe(struct spi_device *spi)
if (ret)
goto error_free_reg;

for (i = 0; i < AD5064_DAC_CHANNELS; ++i) {
for (i = 0; i < st->chip_info->num_channels; ++i) {
st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K;
st->dac_cache[i] = 0x8000;
}
Expand All @@ -368,8 +375,8 @@ static int __devinit ad5064_probe(struct spi_device *spi)
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->info = &ad5064_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = st->chip_info->channel;
indio_dev->num_channels = AD5064_DAC_CHANNELS;
indio_dev->channels = st->chip_info->channels;
indio_dev->num_channels = st->chip_info->num_channels;

ret = iio_device_register(indio_dev);
if (ret)
Expand Down

0 comments on commit 4b7db50

Please sign in to comment.