]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
staging:iio:max1363 add support for 8 bit equivalent devices, max1036-9, max11600-5
authorJonathan Cameron <jic23@cam.ac.uk>
Tue, 4 May 2010 13:43:10 +0000 (14:43 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 11 May 2010 18:36:06 +0000 (11:36 -0700)
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/adc/Kconfig
drivers/staging/iio/adc/max1363_core.c
drivers/staging/iio/adc/max1363_ring.c

index afc8318a96d4f2b3cefb7601f84bf23f5d145c4c..0835fbc86c2ac4efda009e2fc04e20f9c2b39b25 100644 (file)
@@ -10,11 +10,13 @@ config MAX1363
        select MAX1363_RING_BUFFER
        help
          Say yes here to build support for many MAXIM i2c analog to digital
-         convertors (ADC). (max1361, max1362, max1363, max1364, max1136,
-         max1136, max1137, max1138, max1139, max1236, max1237, max11238,
-         max1239, max11606, max11607, max11608, max11609, max11610,
-         max11611, max11612, max11613, max11614, max11615, max11616,
-         max11617) Provides direct access via sysfs.
+         convertors (ADC). (max1361, max1362, max1363, max1364, max1036,
+         max1037, max1038, max1039, max1136, max1136, max1137, max1138,
+         max1139, max1236, max1237, max11238, max1239, max11600, max11601,
+         max11602, max11603, max11604, max11605, max11606, max11607,
+         max11608, max11609, max11610, max11611, max11612, max11613,
+         max11614, max11615, max11616, max11617) Provides direct access
+         via sysfs.
 
 config MAX1363_RING_BUFFER
        bool "MAXIM max1363: use ring buffer"
index c53bf6d8410c5b0667e1bf424d9a325a0d1c463c..fa91cc14c64f02db94395821863a4071ec9c7d0e 100644 (file)
@@ -226,13 +226,24 @@ static ssize_t max1363_read_single_channel(struct device *dev,
                        if (ret)
                                goto error_ret;
                }
-               /* Get reading */
-               data = i2c_master_recv(client, rxbuf, 2);
-               if (data < 0) {
-                       ret = data;
-                       goto error_ret;
+               if (st->chip_info->bits != 8) {
+                       /* Get reading */
+                       data = i2c_master_recv(client, rxbuf, 2);
+                       if (data < 0) {
+                               ret = data;
+                               goto error_ret;
+                       }
+
+                       data = (s32)(rxbuf[1]) | ((s32)(rxbuf[0] & 0x0F)) << 8;
+               } else {
+                       /* Get reading */
+                       data = i2c_master_recv(client, rxbuf, 1);
+                       if (data < 0) {
+                               ret = data;
+                               goto error_ret;
+                       }
+                       data = rxbuf[0];
                }
-               data = (s32)(rxbuf[1]) | ((s32)(rxbuf[0] & 0x0F)) << 8;
        }
        /* Pretty print the result */
        len = sprintf(buf, "%u\n", data);
@@ -508,6 +519,10 @@ enum { max1361,
        max1362,
        max1363,
        max1364,
+       max1036,
+       max1037,
+       max1038,
+       max1039,
        max1136,
        max1137,
        max1138,
@@ -516,6 +531,12 @@ enum { max1361,
        max1237,
        max1238,
        max1239,
+       max11600,
+       max11601,
+       max11602,
+       max11603,
+       max11604,
+       max11605,
        max11606,
        max11607,
        max11608,
@@ -576,6 +597,46 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
                .default_mode = s0to3,
                .dev_attrs = &max1363_dev_attr_group,
                .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max1036",
+               .num_inputs = 4,
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max1236_mode_list,
+               .num_modes = ARRAY_SIZE(max1236_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max1037",
+               .num_inputs = 4,
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max1236_mode_list,
+               .num_modes = ARRAY_SIZE(max1236_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max1038",
+               .num_inputs = 12,
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
+       }, {
+               .name = "max1039",
+               .num_inputs = 12,
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
        }, {
                .name = "max1136",
                .num_inputs = 4,
@@ -656,6 +717,66 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
                .default_mode = s0to11,
                .dev_attrs = &max1238_dev_attr_group,
                .scan_attrs = &max1238_scan_el_group,
+       }, {
+               .name = "max11600",
+               .num_inputs = 4,
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max11601",
+               .num_inputs = 4,
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max11602",
+               .num_inputs = 8,
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .dev_attrs = &max11608_dev_attr_group,
+               .scan_attrs = &max11608_scan_el_group,
+       }, {
+               .name = "max11603",
+               .num_inputs = 8,
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .dev_attrs = &max11608_dev_attr_group,
+               .scan_attrs = &max11608_scan_el_group,
+       }, {
+               .name = "max11604",
+               .num_inputs = 12,
+               .bits = 8,
+               .int_vref_mv = 4098,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
+       }, {
+               .name = "max11605",
+               .num_inputs = 12,
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
        }, {
                .name = "max11606",
                .num_inputs = 4,
@@ -920,6 +1041,10 @@ static const struct i2c_device_id max1363_id[] = {
        { "max1362", max1362 },
        { "max1363", max1363 },
        { "max1364", max1364 },
+       { "max1036", max1036 },
+       { "max1037", max1037 },
+       { "max1038", max1038 },
+       { "max1039", max1039 },
        { "max1136", max1136 },
        { "max1137", max1137 },
        { "max1138", max1138 },
@@ -928,6 +1053,12 @@ static const struct i2c_device_id max1363_id[] = {
        { "max1237", max1237 },
        { "max1238", max1238 },
        { "max1239", max1239 },
+       { "max11600", max11600 },
+       { "max11601", max11601 },
+       { "max11602", max11602 },
+       { "max11603", max11603 },
+       { "max11604", max11604 },
+       { "max11605", max11605 },
        { "max11606", max11606 },
        { "max11607", max11607 },
        { "max11608", max11608 },
index f1e37f2cf4ebdb10a1358ac21959a35c3c7224dc..85fde751a154e7769ff02cb353512ad603e64955 100644 (file)
@@ -55,8 +55,11 @@ int max1363_single_channel_from_ring(long mask, struct max1363_state *st)
                        count++;
                mask >>= 1;
        }
-       return ((int)(ring_data[count*2 + 0] & 0x0F) << 8)
-               + (int)(ring_data[count*2 + 1]);
+       if (st->chip_info->bits != 8)
+               return ((int)(ring_data[count*2 + 0] & 0x0F) << 8)
+                       + (int)(ring_data[count*2 + 1]);
+       else
+               return ring_data[count];
 
 error_free_ring_data:
        kfree(ring_data);
@@ -90,7 +93,10 @@ static int max1363_ring_preenable(struct iio_dev *indio_dev)
 
        numvals = hweight_long(st->current_mode->modemask);
        if (indio_dev->ring->access.set_bpd) {
-               d_size = numvals*2 + sizeof(s64);
+               if (st->chip_info->bits != 8)
+                       d_size = numvals*2 + sizeof(s64);
+               else
+                       d_size = numvals + sizeof(s64);
                if (d_size % 8)
                        d_size += 8 - (d_size % 8);
                indio_dev->ring->access.set_bpd(indio_dev->ring, d_size);
@@ -166,7 +172,10 @@ static void max1363_poll_bh_to_ring(struct work_struct *work_s)
        unsigned long numvals = hweight_long(st->current_mode->modemask);
 
        /* Ensure the timestamp is 8 byte aligned */
-       d_size = numvals*2 + sizeof(s64);
+       if (st->chip_info->bits != 8)
+               d_size = numvals*2 + sizeof(s64);
+       else
+               d_size = numvals + sizeof(s64);
        if (d_size % sizeof(s64))
                d_size += sizeof(s64) - (d_size % sizeof(s64));
 
@@ -184,8 +193,10 @@ static void max1363_poll_bh_to_ring(struct work_struct *work_s)
        rxbuf = kmalloc(d_size, GFP_KERNEL);
        if (rxbuf == NULL)
                return;
-
-       b_sent = i2c_master_recv(st->client, rxbuf, numvals*2);
+       if (st->chip_info->bits != 8)
+               b_sent = i2c_master_recv(st->client, rxbuf, numvals*2);
+       else
+               b_sent = i2c_master_recv(st->client, rxbuf, numvals);
        if (b_sent < 0)
                goto done;