#include <linux/isa.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
+#include <linux/types.h>
#define CIO_DAC_NUM_CHAN 16
/**
* struct cio_dac_iio - IIO device private data structure
* @chan_out_states: channels' output states
- * @base: base port address of the IIO device
+ * @base: base memory address of the DAC device
*/
struct cio_dac_iio {
int chan_out_states[CIO_DAC_NUM_CHAN];
- void __iomem *base;
+ u16 __iomem *base;
};
static int cio_dac_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int val, int val2, long mask)
{
struct cio_dac_iio *const priv = iio_priv(indio_dev);
- const unsigned int chan_addr_offset = 2 * chan->channel;
if (mask != IIO_CHAN_INFO_RAW)
return -EINVAL;
return -EINVAL;
priv->chan_out_states[chan->channel] = val;
- iowrite16(val, priv->base + chan_addr_offset);
+ iowrite16(val, priv->base + chan->channel);
return 0;
}
indio_dev->name = dev_name(dev);
/* initialize DAC outputs to 0V */
- for (i = 0; i < 32; i += 2)
+ for (i = 0; i < CIO_DAC_NUM_CHAN; i++)
iowrite16(0, priv->base + i);
return devm_iio_device_register(dev, indio_dev);