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

Log Message

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

Modified Paths


Diff

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


--- trunk/drivers/staging/iio/accel/Kconfig	2010-05-23 04:20:02 UTC (rev 8811)
+++ trunk/drivers/staging/iio/accel/Kconfig	2010-05-23 04:21:31 UTC (rev 8812)
@@ -49,6 +49,8 @@
 config ADIS16240
        tristate "Analog Devices ADIS16240 Programmable Impact Sensor and Recorder"
        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 adis16240 programmable
 	 impact Sensor and recorder.

Modified: trunk/drivers/staging/iio/accel/adis16240.h (8811 => 8812)


--- trunk/drivers/staging/iio/accel/adis16240.h	2010-05-23 04:20:02 UTC (rev 8811)
+++ trunk/drivers/staging/iio/accel/adis16240.h	2010-05-23 04:21:31 UTC (rev 8812)
@@ -6,64 +6,112 @@
 #define ADIS16240_READ_REG(a)    a
 #define ADIS16240_WRITE_REG(a) ((a) | 0x80)
 
-#define ADIS16240_FLASH_CNT      0x00 /* Flash memory write count */
-#define ADIS16240_SUPPLY_OUT     0x02 /* Output, power supply */
-#define ADIS16240_XACCL_OUT      0x04 /* Output, x-axis accelerometer */
-#define ADIS16240_YACCL_OUT      0x06 /* Output, y-axis accelerometer */
-#define ADIS16240_ZACCL_OUT      0x08 /* Output, z-axis accelerometer */
-#define ADIS16240_AUX_ADC        0x0A /* Output, auxiliary ADC input */
-#define ADIS16240_TEMP_OUT       0x0C /* Output, temperature */
-#define ADIS16240_XPEAK_OUT      0x0E /* Output, x-axis acceleration peak */
-#define ADIS16240_YPEAK_OUT      0x10 /* Output, y-axis acceleration peak */
-#define ADIS16240_ZPEAK_OUT      0x12 /* Output, z-axis acceleration peak */
-#define ADIS16240_XYZPEAK_OUT    0x14 /* Output, sum-of-squares acceleration peak */
-#define ADIS16240_CAPT_BUF1      0x16 /* Output, Capture Buffer 1, X and Y acceleration */
-#define ADIS16240_CAPT_BUF2      0x18 /* Output, Capture Buffer 2, Z acceleration */
-#define ADIS16240_DIAG_STAT      0x1A /* Diagnostic, error flags */
-#define ADIS16240_EVNT_CNTR      0x1C /* Diagnostic, event counter */
-#define ADIS16240_CHK_SUM        0x1E /* Diagnostic, check sum value from firmware test */
-#define ADIS16240_XACCL_OFF      0x20 /* Calibration, x-axis acceleration offset adjustment */
-#define ADIS16240_YACCL_OFF      0x22 /* Calibration, y-axis acceleration offset adjustment */
-#define ADIS16240_ZACCL_OFF      0x24 /* Calibration, z-axis acceleration offset adjustment */
-#define ADIS16240_CLK_TIME       0x2E /* Clock, hour and minute */
-#define ADIS16240_CLK_DATE       0x30 /* Clock, month and day */
-#define ADIS16240_CLK_YEAR       0x32 /* Clock, year */
-#define ADIS16240_WAKE_TIME      0x34 /* Wake-up setting, hour and minute */
-#define ADIS16240_WAKE_DATE      0x36 /* Wake-up setting, month and day */
-#define ADIS16240_ALM_MAG1       0x38 /* Alarm 1 amplitude threshold */
-#define ADIS16240_ALM_MAG2       0x3A /* Alarm 2 amplitude threshold */
-#define ADIS16240_ALM_CTRL       0x3C /* Alarm control */
-#define ADIS16240_XTRIG_CTRL     0x3E /* Capture, external trigger control */
-#define ADIS16240_CAPT_PNTR      0x40 /* Capture, address pointer */
-#define ADIS16240_CAPT_CTRL      0x42 /* Capture, configuration and control */
-#define ADIS16240_GPIO_CTRL      0x44 /* General-purpose digital input/output control */
-#define ADIS16240_MSC_CTRL       0x46 /* Miscellaneous control */
-#define ADIS16240_SMPL_PRD       0x48 /* Internal sample period (rate) control */
-#define ADIS16240_GLOB_CMD       0x4A /* System command */
+/* Flash memory write count */
+#define ADIS16240_FLASH_CNT      0x00
+/* Output, power supply */
+#define ADIS16240_SUPPLY_OUT     0x02
+/* Output, x-axis accelerometer */
+#define ADIS16240_XACCL_OUT      0x04
+/* Output, y-axis accelerometer */
+#define ADIS16240_YACCL_OUT      0x06
+/* Output, z-axis accelerometer */
+#define ADIS16240_ZACCL_OUT      0x08
+/* Output, auxiliary ADC input */
+#define ADIS16240_AUX_ADC        0x0A
+/* Output, temperature */
+#define ADIS16240_TEMP_OUT       0x0C
+/* Output, x-axis acceleration peak */
+#define ADIS16240_XPEAK_OUT      0x0E
+/* Output, y-axis acceleration peak */
+#define ADIS16240_YPEAK_OUT      0x10
+/* Output, z-axis acceleration peak */
+#define ADIS16240_ZPEAK_OUT      0x12
+/* Output, sum-of-squares acceleration peak */
+#define ADIS16240_XYZPEAK_OUT    0x14
+/* Output, Capture Buffer 1, X and Y acceleration */
+#define ADIS16240_CAPT_BUF1      0x16
+/* Output, Capture Buffer 2, Z acceleration */
+#define ADIS16240_CAPT_BUF2      0x18
+/* Diagnostic, error flags */
+#define ADIS16240_DIAG_STAT      0x1A
+/* Diagnostic, event counter */
+#define ADIS16240_EVNT_CNTR      0x1C
+/* Diagnostic, check sum value from firmware test */
+#define ADIS16240_CHK_SUM        0x1E
+/* Calibration, x-axis acceleration offset adjustment */
+#define ADIS16240_XACCL_OFF      0x20
+/* Calibration, y-axis acceleration offset adjustment */
+#define ADIS16240_YACCL_OFF      0x22
+/* Calibration, z-axis acceleration offset adjustment */
+#define ADIS16240_ZACCL_OFF      0x24
+/* Clock, hour and minute */
+#define ADIS16240_CLK_TIME       0x2E
+/* Clock, month and day */
+#define ADIS16240_CLK_DATE       0x30
+/* Clock, year */
+#define ADIS16240_CLK_YEAR       0x32
+/* Wake-up setting, hour and minute */
+#define ADIS16240_WAKE_TIME      0x34
+/* Wake-up setting, month and day */
+#define ADIS16240_WAKE_DATE      0x36
+/* Alarm 1 amplitude threshold */
+#define ADIS16240_ALM_MAG1       0x38
+/* Alarm 2 amplitude threshold */
+#define ADIS16240_ALM_MAG2       0x3A
+/* Alarm control */
+#define ADIS16240_ALM_CTRL       0x3C
+/* Capture, external trigger control */
+#define ADIS16240_XTRIG_CTRL     0x3E
+/* Capture, address pointer */
+#define ADIS16240_CAPT_PNTR      0x40
+/* Capture, configuration and control */
+#define ADIS16240_CAPT_CTRL      0x42
+/* General-purpose digital input/output control */
+#define ADIS16240_GPIO_CTRL      0x44
+/* Miscellaneous control */
+#define ADIS16240_MSC_CTRL       0x46
+/* Internal sample period (rate) control */
+#define ADIS16240_SMPL_PRD       0x48
+/* System command */
+#define ADIS16240_GLOB_CMD       0x4A
 
 #define ADIS16240_OUTPUTS        6
 
 /* MSC_CTRL */
-#define ADIS16240_MSC_CTRL_XYZPEAK_OUT_EN	(1 << 15) /* Enables sum-of-squares output (XYZPEAK_OUT) */
-#define ADIS16240_MSC_CTRL_X_Y_ZPEAK_OUT_EN	(1 << 14) /* Enables peak tracking output
-							  (XPEAK_OUT, YPEAK_OUT, and ZPEAK_OUT) */
-#define ADIS16240_MSC_CTRL_SELF_TEST_EN	        (1 << 8)  /* Self-test enable: 1 = apply electrostatic force,
-							  0 = disabled */
-#define ADIS16240_MSC_CTRL_DATA_RDY_EN	        (1 << 2)  /* Data-ready enable: 1 = enabled, 0 = disabled */
-#define ADIS16240_MSC_CTRL_ACTIVE_HIGH	        (1 << 1)  /* Data-ready polarity: 1 = active high, 0 = active low */
-#define ADIS16240_MSC_CTRL_DATA_RDY_DIO2	(1 << 0)  /* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
+/* Enables sum-of-squares output (XYZPEAK_OUT) */
+#define ADIS16240_MSC_CTRL_XYZPEAK_OUT_EN	(1 << 15)
+/* Enables peak tracking output (XPEAK_OUT, YPEAK_OUT, and ZPEAK_OUT) */
+#define ADIS16240_MSC_CTRL_X_Y_ZPEAK_OUT_EN	(1 << 14)
+/* Self-test enable: 1 = apply electrostatic force, 0 = disabled */
+#define ADIS16240_MSC_CTRL_SELF_TEST_EN	        (1 << 8)
+/* Data-ready enable: 1 = enabled, 0 = disabled */
+#define ADIS16240_MSC_CTRL_DATA_RDY_EN	        (1 << 2)
+/* Data-ready polarity: 1 = active high, 0 = active low */
+#define ADIS16240_MSC_CTRL_ACTIVE_HIGH	        (1 << 1)
+/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
+#define ADIS16240_MSC_CTRL_DATA_RDY_DIO2	(1 << 0)
 
 /* DIAG_STAT */
-#define ADIS16240_DIAG_STAT_ALARM2      (1<<9) /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16240_DIAG_STAT_ALARM1      (1<<8) /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16240_DIAG_STAT_CPT_BUF_FUL (1<<7) /* Capture buffer full: 1 = capture buffer is full */
-#define ADIS16240_DIAG_STAT_CHKSUM      (1<<6) /* Flash test, checksum flag: 1 = mismatch, 0 = match */
-#define ADIS16240_DIAG_STAT_PWRON_FAIL  (1<<5) /* Power-on, self-test flag: 1 = failure, 0 = pass */
-#define ADIS16240_DIAG_STAT_PWRON_BUSY  (1<<4) /* Power-on self-test: 1 = in-progress, 0 = complete */
-#define ADIS16240_DIAG_STAT_SPI_FAIL	(1<<3) /* SPI communications failure */
-#define ADIS16240_DIAG_STAT_FLASH_UPT	(1<<2) /* Flash update failure */
-#define ADIS16240_DIAG_STAT_POWER_HIGH	(1<<1) /* Power supply above 3.625 V */
-#define ADIS16240_DIAG_STAT_POWER_LOW	(1<<0) /* Power supply below 3.15 V */
+/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
+#define ADIS16240_DIAG_STAT_ALARM2      (1<<9)
+/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
+#define ADIS16240_DIAG_STAT_ALARM1      (1<<8)
+/* Capture buffer full: 1 = capture buffer is full */
+#define ADIS16240_DIAG_STAT_CPT_BUF_FUL (1<<7)
+/* Flash test, checksum flag: 1 = mismatch, 0 = match */
+#define ADIS16240_DIAG_STAT_CHKSUM      (1<<6)
+/* Power-on, self-test flag: 1 = failure, 0 = pass */
+#define ADIS16240_DIAG_STAT_PWRON_FAIL  (1<<5)
+/* Power-on self-test: 1 = in-progress, 0 = complete */
+#define ADIS16240_DIAG_STAT_PWRON_BUSY  (1<<4)
+/* SPI communications failure */
+#define ADIS16240_DIAG_STAT_SPI_FAIL	(1<<3)
+/* Flash update failure */
+#define ADIS16240_DIAG_STAT_FLASH_UPT	(1<<2)
+/* Power supply above 3.625 V */
+#define ADIS16240_DIAG_STAT_POWER_HIGH	(1<<1)
+ /* Power supply below 3.15 V */
+#define ADIS16240_DIAG_STAT_POWER_LOW	(1<<0)
 
 /* GLOB_CMD */
 #define ADIS16240_GLOB_CMD_RESUME	(1<<8)

Modified: trunk/drivers/staging/iio/accel/adis16240_core.c (8811 => 8812)


--- trunk/drivers/staging/iio/accel/adis16240_core.c	2010-05-23 04:20:02 UTC (rev 8811)
+++ trunk/drivers/staging/iio/accel/adis16240_core.c	2010-05-23 04:21:31 UTC (rev 8812)
@@ -21,7 +21,6 @@
 #include "../iio.h"
 #include "../sysfs.h"
 #include "accel.h"
-#include "../imu/volt.h"
 #include "../adc/adc.h"
 
 #include "adis16240.h"
@@ -142,8 +141,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];
@@ -375,25 +375,30 @@
 	return ret;
 }
 
-static IIO_DEV_ATTR_VOLT(supply, adis16240_read_10bit_unsigned,
+static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16240_read_10bit_unsigned,
 		ADIS16240_SUPPLY_OUT);
-static IIO_DEV_ATTR_VOLT(aux, adis16240_read_10bit_signed,
+static IIO_DEV_ATTR_IN_RAW(0, adis16240_read_10bit_signed,
 		ADIS16240_AUX_ADC);
-static IIO_CONST_ATTR(volt_supply_scale, "0.00488");
+static IIO_CONST_ATTR(in_supply_scale, "0.00488");
 static IIO_DEV_ATTR_ACCEL_X(adis16240_read_10bit_signed,
 		ADIS16240_XACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_XPEAK(adis16240_read_10bit_signed,
-		ADIS16240_XPEAK_OUT);
+static IIO_DEVICE_ATTR(accel_x_peak_raw, S_IRUGO,
+		       adis16240_read_10bit_signed, NULL,
+		       ADIS16240_XPEAK_OUT);
 static IIO_DEV_ATTR_ACCEL_Y(adis16240_read_10bit_signed,
 		ADIS16240_YACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_YPEAK(adis16240_read_10bit_signed,
-		ADIS16240_YPEAK_OUT);
+static IIO_DEVICE_ATTR(accel_y_peak_raw, S_IRUGO,
+		       adis16240_read_10bit_signed, NULL,
+		       ADIS16240_YPEAK_OUT);
 static IIO_DEV_ATTR_ACCEL_Z(adis16240_read_10bit_signed,
 		ADIS16240_ZACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_ZPEAK(adis16240_read_10bit_signed,
-		ADIS16240_ZPEAK_OUT);
-static IIO_DEV_ATTR_ACCEL_XYZPEAK(adis16240_read_12bit_signed,
-		ADIS16240_XYZPEAK_OUT);
+static IIO_DEVICE_ATTR(accel_z_peak_raw, S_IRUGO,
+		       adis16240_read_10bit_signed, NULL,
+		       ADIS16240_ZPEAK_OUT);
+
+static IIO_DEVICE_ATTR(accel_xyz_squared_peak_raw, S_IRUGO,
+		       adis16240_read_12bit_signed, NULL,
+		       ADIS16240_XYZPEAK_OUT);
 static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO,
 		adis16240_read_10bit_signed,
 		adis16240_write_16bit,
@@ -406,10 +411,10 @@
 		adis16240_read_10bit_signed,
 		adis16240_write_16bit,
 		ADIS16240_ZACCL_OFF);
-static IIO_DEV_ATTR_TEMP(adis16240_read_10bit_unsigned);
+static IIO_DEV_ATTR_TEMP_RAW(adis16240_read_10bit_unsigned);
 static IIO_CONST_ATTR(temp_scale, "0.244");
 
-static IIO_DEV_ATTR_RESET(adis16240_write_reset);
+static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16240_write_reset, 0);
 
 static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("4096");
 
@@ -424,20 +429,20 @@
 };
 
 static struct attribute *adis16240_attributes[] = {
-	&iio_dev_attr_volt_supply.dev_attr.attr,
-	&iio_const_attr_volt_supply_scale.dev_attr.attr,
-	&iio_dev_attr_volt_aux.dev_attr.attr,
-	&iio_dev_attr_accel_x.dev_attr.attr,
+	&iio_dev_attr_in_supply_raw.dev_attr.attr,
+	&iio_const_attr_in_supply_scale.dev_attr.attr,
+	&iio_dev_attr_in0_raw.dev_attr.attr,
+	&iio_dev_attr_accel_x_raw.dev_attr.attr,
 	&iio_dev_attr_accel_x_offset.dev_attr.attr,
-	&iio_dev_attr_accel_xpeak.dev_attr.attr,
-	&iio_dev_attr_accel_y.dev_attr.attr,
+	&iio_dev_attr_accel_x_peak_raw.dev_attr.attr,
+	&iio_dev_attr_accel_y_raw.dev_attr.attr,
 	&iio_dev_attr_accel_y_offset.dev_attr.attr,
-	&iio_dev_attr_accel_ypeak.dev_attr.attr,
-	&iio_dev_attr_accel_z.dev_attr.attr,
+	&iio_dev_attr_accel_y_peak_raw.dev_attr.attr,
+	&iio_dev_attr_accel_z_raw.dev_attr.attr,
 	&iio_dev_attr_accel_z_offset.dev_attr.attr,
-	&iio_dev_attr_accel_zpeak.dev_attr.attr,
-	&iio_dev_attr_accel_xyzpeak.dev_attr.attr,
-	&iio_dev_attr_temp.dev_attr.attr,
+	&iio_dev_attr_accel_z_peak_raw.dev_attr.attr,
+	&iio_dev_attr_accel_xyz_squared_peak_raw.dev_attr.attr,
+	&iio_dev_attr_temp_raw.dev_attr.attr,
 	&iio_const_attr_temp_scale.dev_attr.attr,
 	&iio_const_attr_available_sampling_frequency.dev_attr.attr,
 	&iio_dev_attr_reset.dev_attr.attr,
@@ -590,5 +595,5 @@
 module_exit(adis16240_exit);
 
 MODULE_AUTHOR("Barry Song <[email protected]>");
-MODULE_DESCRIPTION("Analog Devices Programmable Impact Sensor and Recorder driver");
+MODULE_DESCRIPTION("Analog Devices Programmable Impact Sensor and Recorder");
 MODULE_LICENSE("GPL v2");

Modified: trunk/drivers/staging/iio/accel/adis16240_ring.c (8811 => 8812)


--- trunk/drivers/staging/iio/accel/adis16240_ring.c	2010-05-23 04:20:02 UTC (rev 8811)
+++ trunk/drivers/staging/iio/accel/adis16240_ring.c	2010-05-23 04:21:31 UTC (rev 8812)
@@ -39,7 +39,7 @@
 static IIO_SCAN_EL_C(temp, ADIS16240_SCAN_TEMP, IIO_UNSIGNED(10),
 		ADIS16240_TEMP_OUT, NULL);
 
-static IIO_SCAN_EL_TIMESTAMP;
+static IIO_SCAN_EL_TIMESTAMP(6);
 
 static struct attribute *adis16240_scan_el_attrs[] = {
 	&iio_scan_el_supply.dev_attr.attr,
@@ -93,7 +93,8 @@
 		xfers[i].len = 2;
 		xfers[i].delay_usecs = 30;
 		xfers[i].tx_buf = st->tx + 2 * i;
-		st->tx[2 * i] = ADIS16240_READ_REG(ADIS16240_SUPPLY_OUT + 2 * i);
+		st->tx[2 * i]
+			= ADIS16240_READ_REG(ADIS16240_SUPPLY_OUT + 2 * i);
 		st->tx[2 * i + 1] = 0;
 		if (i >= 1)
 			xfers[i].rx_buf = rx + 2 * (i - 1);
@@ -159,8 +160,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 sizeof(s64) and data */
+				size = (((indio_dev->scan_count * sizeof(s16))
+					 + sizeof(s64) - 1)
+					& ~(sizeof(s64) - 1))
 					+ sizeof(s64);
 			else /* Timestamp only  */
 				size = sizeof(s64);
@@ -242,7 +245,7 @@
 
 int adis16240_initialize_ring(struct iio_ring_buffer *ring)
 {
-	return iio_ring_buffer_register(ring);
+	return iio_ring_buffer_register(ring, 0);
 }
 
 void adis16240_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