Title: [8811] trunk/drivers/staging/iio/accel: staging:iio: merge the ADIS16209 driver as was added to mainline
Revision
8811
Author
vapier
Date
2010-05-23 00:20:02 -0400 (Sun, 23 May 2010)

Log Message

staging:iio: merge the ADIS16209 driver as was added to mainline

Modified Paths


Diff

Modified: trunk/drivers/staging/iio/accel/Kconfig (8810 => 8811)


--- trunk/drivers/staging/iio/accel/Kconfig	2010-05-23 04:17:11 UTC (rev 8810)
+++ trunk/drivers/staging/iio/accel/Kconfig	2010-05-23 04:20:02 UTC (rev 8811)
@@ -33,6 +33,8 @@
 config ADIS16209
        tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer"
        depends on SPI
+       select IIO_TRIGGER if IIO_RING_BUFFER
+       select IIO_SW_RING if IIO_RING_BUFFER
        help
          Say yes here to build support for Analog Devices adis16209 dual-axis digital inclinometer
 	 and accelerometer.

Modified: trunk/drivers/staging/iio/accel/adis16209.h (8810 => 8811)


--- trunk/drivers/staging/iio/accel/adis16209.h	2010-05-23 04:17:11 UTC (rev 8810)
+++ trunk/drivers/staging/iio/accel/adis16209.h	2010-05-23 04:20:02 UTC (rev 8811)
@@ -6,52 +6,90 @@
 #define ADIS16209_READ_REG(a)    a
 #define ADIS16209_WRITE_REG(a) ((a) | 0x80)
 
-#define ADIS16209_FLASH_CNT      0x00 /* Flash memory write count */
-#define ADIS16209_SUPPLY_OUT     0x02 /* Output, power supply */
-#define ADIS16209_XACCL_OUT      0x04 /* Output, x-axis accelerometer */
-#define ADIS16209_YACCL_OUT      0x06 /* Output, y-axis accelerometer */
-#define ADIS16209_AUX_ADC        0x08 /* Output, auxiliary ADC input */
-#define ADIS16209_TEMP_OUT       0x0A /* Output, temperature */
-#define ADIS16209_XINCL_OUT      0x0C /* Output, x-axis inclination */
-#define ADIS16209_YINCL_OUT      0x0E /* Output, y-axis inclination */
-#define ADIS16209_ROT_OUT        0x10 /* Output, +/-180 vertical rotational position */
-#define ADIS16209_XACCL_NULL     0x12 /* Calibration, x-axis acceleration offset null */
-#define ADIS16209_YACCL_NULL     0x14 /* Calibration, y-axis acceleration offset null */
-#define ADIS16209_XINCL_NULL     0x16 /* Calibration, x-axis inclination offset null */
-#define ADIS16209_YINCL_NULL     0x18 /* Calibration, y-axis inclination offset null */
-#define ADIS16209_ROT_NULL       0x1A /* Calibration, vertical rotation offset null */
-#define ADIS16209_ALM_MAG1       0x20 /* Alarm 1 amplitude threshold */
-#define ADIS16209_ALM_MAG2       0x22 /* Alarm 2 amplitude threshold */
-#define ADIS16209_ALM_SMPL1      0x24 /* Alarm 1, sample period */
-#define ADIS16209_ALM_SMPL2      0x26 /* Alarm 2, sample period */
-#define ADIS16209_ALM_CTRL       0x28 /* Alarm control */
-#define ADIS16209_AUX_DAC        0x30 /* Auxiliary DAC data */
-#define ADIS16209_GPIO_CTRL      0x32 /* General-purpose digital input/output control */
-#define ADIS16209_MSC_CTRL       0x34 /* Miscellaneous control */
-#define ADIS16209_SMPL_PRD       0x36 /* Internal sample period (rate) control */
-#define ADIS16209_AVG_CNT        0x38 /* Operation, filter configuration */
-#define ADIS16209_SLP_CNT        0x3A /* Operation, sleep mode control */
-#define ADIS16209_DIAG_STAT      0x3C /* Diagnostics, system status register */
-#define ADIS16209_GLOB_CMD       0x3E /* Operation, system command register */
+/* Flash memory write count */
+#define ADIS16209_FLASH_CNT      0x00
+/* Output, power supply */
+#define ADIS16209_SUPPLY_OUT     0x02
+/* Output, x-axis accelerometer */
+#define ADIS16209_XACCL_OUT      0x04
+/* Output, y-axis accelerometer */
+#define ADIS16209_YACCL_OUT      0x06
+/* Output, auxiliary ADC input */
+#define ADIS16209_AUX_ADC        0x08
+/* Output, temperature */
+#define ADIS16209_TEMP_OUT       0x0A
+/* Output, x-axis inclination */
+#define ADIS16209_XINCL_OUT      0x0C
+/* Output, y-axis inclination */
+#define ADIS16209_YINCL_OUT      0x0E
+/* Output, +/-180 vertical rotational position */
+#define ADIS16209_ROT_OUT        0x10
+/* Calibration, x-axis acceleration offset null */
+#define ADIS16209_XACCL_NULL     0x12
+/* Calibration, y-axis acceleration offset null */
+#define ADIS16209_YACCL_NULL     0x14
+/* Calibration, x-axis inclination offset null */
+#define ADIS16209_XINCL_NULL     0x16
+/* Calibration, y-axis inclination offset null */
+#define ADIS16209_YINCL_NULL     0x18
+/* Calibration, vertical rotation offset null */
+#define ADIS16209_ROT_NULL       0x1A
+/* Alarm 1 amplitude threshold */
+#define ADIS16209_ALM_MAG1       0x20
+/* Alarm 2 amplitude threshold */
+#define ADIS16209_ALM_MAG2       0x22
+/* Alarm 1, sample period */
+#define ADIS16209_ALM_SMPL1      0x24
+/* Alarm 2, sample period */
+#define ADIS16209_ALM_SMPL2      0x26
+/* Alarm control */
+#define ADIS16209_ALM_CTRL       0x28
+/* Auxiliary DAC data */
+#define ADIS16209_AUX_DAC        0x30
+/* General-purpose digital input/output control */
+#define ADIS16209_GPIO_CTRL      0x32
+/* Miscellaneous control */
+#define ADIS16209_MSC_CTRL       0x34
+/* Internal sample period (rate) control */
+#define ADIS16209_SMPL_PRD       0x36
+/* Operation, filter configuration */
+#define ADIS16209_AVG_CNT        0x38
+/* Operation, sleep mode control */
+#define ADIS16209_SLP_CNT        0x3A
+/* Diagnostics, system status register */
+#define ADIS16209_DIAG_STAT      0x3C
+/* Operation, system command register */
+#define ADIS16209_GLOB_CMD       0x3E
 
 #define ADIS16209_OUTPUTS        8
 
 /* MSC_CTRL */
-#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST	(1 << 10) /* Self-test at power-on: 1 = disabled, 0 = enabled */
-#define ADIS16209_MSC_CTRL_SELF_TEST_EN	        (1 << 8)  /* Self-test enable */
-#define ADIS16209_MSC_CTRL_DATA_RDY_EN	        (1 << 2)  /* Data-ready enable: 1 = enabled, 0 = disabled */
-#define ADIS16209_MSC_CTRL_ACTIVE_HIGH	        (1 << 1)  /* Data-ready polarity: 1 = active high, 0 = active low */
-#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2	(1 << 0)  /* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
+/* Self-test at power-on: 1 = disabled, 0 = enabled */
+#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST	(1 << 10)
+/* Self-test enable */
+#define ADIS16209_MSC_CTRL_SELF_TEST_EN	        (1 << 8)
+/* Data-ready enable: 1 = enabled, 0 = disabled */
+#define ADIS16209_MSC_CTRL_DATA_RDY_EN	        (1 << 2)
+/* Data-ready polarity: 1 = active high, 0 = active low */
+#define ADIS16209_MSC_CTRL_ACTIVE_HIGH	        (1 << 1)
+/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
+#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2	(1 << 0)
 
 /* DIAG_STAT */
-#define ADIS16209_DIAG_STAT_ALARM2        (1<<9) /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16209_DIAG_STAT_ALARM1        (1<<8) /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16209_DIAG_STAT_SELFTEST_FAIL (1<<5) /* Self-test diagnostic error flag: 1 = error condition,
-						0 = normal operation */
-#define ADIS16209_DIAG_STAT_SPI_FAIL	  (1<<3) /* SPI communications failure */
-#define ADIS16209_DIAG_STAT_FLASH_UPT	  (1<<2) /* Flash update failure */
-#define ADIS16209_DIAG_STAT_POWER_HIGH	  (1<<1) /* Power supply above 3.625 V */
-#define ADIS16209_DIAG_STAT_POWER_LOW	  (1<<0) /* Power supply below 3.15 V */
+/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
+#define ADIS16209_DIAG_STAT_ALARM2        (1<<9)
+/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
+#define ADIS16209_DIAG_STAT_ALARM1        (1<<8)
+/* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */
+#define ADIS16209_DIAG_STAT_SELFTEST_FAIL (1<<5)
+/* SPI communications failure */
+#define ADIS16209_DIAG_STAT_SPI_FAIL	  (1<<3)
+/* Flash update failure */
+#define ADIS16209_DIAG_STAT_FLASH_UPT	  (1<<2)
+/* Power supply above 3.625 V */
+#define ADIS16209_DIAG_STAT_POWER_HIGH	  (1<<1)
+/* Power supply below 3.15 V */
+#define ADIS16209_DIAG_STAT_POWER_LOW	  (1<<0)
 
 /* GLOB_CMD */
 #define ADIS16209_GLOB_CMD_SW_RESET	(1<<7)

Modified: trunk/drivers/staging/iio/accel/adis16209_core.c (8810 => 8811)


--- trunk/drivers/staging/iio/accel/adis16209_core.c	2010-05-23 04:17:11 UTC (rev 8810)
+++ trunk/drivers/staging/iio/accel/adis16209_core.c	2010-05-23 04:20:02 UTC (rev 8811)
@@ -21,7 +21,7 @@
 #include "../iio.h"
 #include "../sysfs.h"
 #include "accel.h"
-#include "../imu/volt.h"
+#include "inclinometer.h"
 #include "../gyro/gyro.h"
 #include "../adc/adc.h"
 
@@ -139,8 +139,9 @@
 	spi_message_add_tail(&xfers[1], &msg);
 	ret = spi_sync(st->us, &msg);
 	if (ret) {
-		dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
-				lower_reg_address);
+		dev_err(&st->us->dev,
+			"problem when reading 16 bit register 0x%02X",
+			lower_reg_address);
 		goto error_ret;
 	}
 	*val = (st->rx[0] << 8) | st->rx[1];
@@ -387,12 +388,12 @@
 	return ret;
 }
 
-static IIO_DEV_ATTR_VOLT(supply, adis16209_read_14bit_unsigned,
+static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16209_read_14bit_unsigned,
 		ADIS16209_SUPPLY_OUT);
-static IIO_CONST_ATTR(volt_supply_scale, "0.30518");
-static IIO_DEV_ATTR_VOLT(aux, adis16209_read_12bit_unsigned,
+static IIO_CONST_ATTR(in_supply_scale, "0.30518");
+static IIO_DEV_ATTR_IN_RAW(0, adis16209_read_12bit_unsigned,
 		ADIS16209_AUX_ADC);
-static IIO_CONST_ATTR(volt_aux_scale, "0.6105");
+static IIO_CONST_ATTR(in0_scale, "0.6105");
 
 static IIO_DEV_ATTR_ACCEL_X(adis16209_read_14bit_signed,
 		ADIS16209_XACCL_OUT);
@@ -422,14 +423,14 @@
 		ADIS16209_YACCL_NULL);
 static IIO_CONST_ATTR(incli_scale, "0.025");
 
-static IIO_DEV_ATTR_ROT(adis16209_read_14bit_signed,
-		ADIS16209_ROT_OUT);
+static IIO_DEVICE_ATTR(rot_raw, S_IRUGO, adis16209_read_14bit_signed,
+		       NULL, ADIS16209_ROT_OUT);
 
 static IIO_DEV_ATTR_TEMP(adis16209_read_temp);
 static IIO_CONST_ATTR(temp_offset, "25");
 static IIO_CONST_ATTR(temp_scale, "-0.47");
 
-static IIO_DEV_ATTR_RESET(adis16209_write_reset);
+static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16209_write_reset, 0);
 
 static IIO_CONST_ATTR(name, "adis16209");
 
@@ -442,26 +443,26 @@
 };
 
 static struct attribute *adis16209_attributes[] = {
-	&iio_dev_attr_volt_supply.dev_attr.attr,
-	&iio_const_attr_volt_supply_scale.dev_attr.attr,
+	&iio_dev_attr_in_supply_raw.dev_attr.attr,
+	&iio_const_attr_in_supply_scale.dev_attr.attr,
 	&iio_dev_attr_temp.dev_attr.attr,
 	&iio_const_attr_temp_offset.dev_attr.attr,
 	&iio_const_attr_temp_scale.dev_attr.attr,
 	&iio_dev_attr_reset.dev_attr.attr,
 	&iio_const_attr_name.dev_attr.attr,
-	&iio_dev_attr_volt_aux.dev_attr.attr,
-	&iio_const_attr_volt_aux_scale.dev_attr.attr,
-	&iio_dev_attr_accel_x.dev_attr.attr,
-	&iio_dev_attr_accel_y.dev_attr.attr,
+	&iio_dev_attr_in0_raw.dev_attr.attr,
+	&iio_const_attr_in0_scale.dev_attr.attr,
+	&iio_dev_attr_accel_x_raw.dev_attr.attr,
+	&iio_dev_attr_accel_y_raw.dev_attr.attr,
 	&iio_dev_attr_accel_x_offset.dev_attr.attr,
 	&iio_dev_attr_accel_y_offset.dev_attr.attr,
 	&iio_const_attr_accel_scale.dev_attr.attr,
-	&iio_dev_attr_incli_x.dev_attr.attr,
-	&iio_dev_attr_incli_y.dev_attr.attr,
+	&iio_dev_attr_incli_x_raw.dev_attr.attr,
+	&iio_dev_attr_incli_y_raw.dev_attr.attr,
 	&iio_dev_attr_incli_x_offset.dev_attr.attr,
 	&iio_dev_attr_incli_y_offset.dev_attr.attr,
 	&iio_const_attr_incli_scale.dev_attr.attr,
-	&iio_dev_attr_rot.dev_attr.attr,
+	&iio_dev_attr_rot_raw.dev_attr.attr,
 	NULL
 };
 
@@ -610,5 +611,5 @@
 module_exit(adis16209_exit);
 
 MODULE_AUTHOR("Barry Song <[email protected]>");
-MODULE_DESCRIPTION("Analog Devices ADIS16209 Programmable Digital Vibration Sensor driver");
+MODULE_DESCRIPTION("Analog Devices ADIS16209 Digital Vibration Sensor driver");
 MODULE_LICENSE("GPL v2");

Modified: trunk/drivers/staging/iio/accel/adis16209_ring.c (8810 => 8811)


--- trunk/drivers/staging/iio/accel/adis16209_ring.c	2010-05-23 04:17:11 UTC (rev 8810)
+++ trunk/drivers/staging/iio/accel/adis16209_ring.c	2010-05-23 04:20:02 UTC (rev 8811)
@@ -43,7 +43,7 @@
 static IIO_SCAN_EL_C(rot, ADIS16209_SCAN_ROT, IIO_SIGNED(14),
 		     ADIS16209_ROT_OUT, NULL);
 
-static IIO_SCAN_EL_TIMESTAMP;
+static IIO_SCAN_EL_TIMESTAMP(8);
 
 static struct attribute *adis16209_scan_el_attrs[] = {
 	&iio_scan_el_supply.dev_attr.attr,
@@ -99,7 +99,8 @@
 		xfers[i].len = 2;
 		xfers[i].delay_usecs = 20;
 		xfers[i].tx_buf = st->tx + 2 * i;
-		st->tx[2 * i] = ADIS16209_READ_REG(ADIS16209_SUPPLY_OUT + 2 * i);
+		st->tx[2 * i]
+			= ADIS16209_READ_REG(ADIS16209_SUPPLY_OUT + 2 * i);
 		st->tx[2 * i + 1] = 0;
 		if (i >= 1)
 			xfers[i].rx_buf = rx + 2 * (i - 1);
@@ -169,8 +170,10 @@
 	if (indio_dev->ring->access.set_bpd) {
 		if (indio_dev->scan_timestamp)
 			if (indio_dev->scan_count)
-				/* Timestamp and data, let timestamp aligned with sizeof(s64) */
-				size = (((indio_dev->scan_count * sizeof(s16)) + sizeof(s64) - 1) & ~(sizeof(s64) - 1))
+				/* Timestamp (aligned to s64) and data */
+				size = (((indio_dev->scan_count * sizeof(s16))
+					 + sizeof(s64) - 1)
+					& ~(sizeof(s64) - 1))
 					+ sizeof(s64);
 			else /* Timestamp only  */
 				size = sizeof(s64);
@@ -254,7 +257,7 @@
 
 int adis16209_initialize_ring(struct iio_ring_buffer *ring)
 {
-	return iio_ring_buffer_register(ring);
+	return iio_ring_buffer_register(ring, 0);
 }
 
 void adis16209_uninitialize_ring(struct iio_ring_buffer *ring)
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to