1e27c7292SMichael Hennerich /* 2e27c7292SMichael Hennerich * include/linux/input/adxl34x.h 3e27c7292SMichael Hennerich * 4e27c7292SMichael Hennerich * Digital Accelerometer characteristics are highly application specific 5e27c7292SMichael Hennerich * and may vary between boards and models. The platform_data for the 6e27c7292SMichael Hennerich * device's "struct device" holds this information. 7e27c7292SMichael Hennerich * 8e27c7292SMichael Hennerich * Copyright 2009 Analog Devices Inc. 9e27c7292SMichael Hennerich * 10e27c7292SMichael Hennerich * Licensed under the GPL-2 or later. 11e27c7292SMichael Hennerich */ 12e27c7292SMichael Hennerich 13e27c7292SMichael Hennerich #ifndef __LINUX_INPUT_ADXL34X_H__ 14e27c7292SMichael Hennerich #define __LINUX_INPUT_ADXL34X_H__ 15e27c7292SMichael Hennerich 16e27c7292SMichael Hennerich struct adxl34x_platform_data { 17e27c7292SMichael Hennerich 18e27c7292SMichael Hennerich /* 19e27c7292SMichael Hennerich * X,Y,Z Axis Offset: 20e27c7292SMichael Hennerich * offer user offset adjustments in twoscompliment 21e27c7292SMichael Hennerich * form with a scale factor of 15.6 mg/LSB (i.e. 0x7F = +2 g) 22e27c7292SMichael Hennerich */ 23e27c7292SMichael Hennerich 24e27c7292SMichael Hennerich s8 x_axis_offset; 25e27c7292SMichael Hennerich s8 y_axis_offset; 26e27c7292SMichael Hennerich s8 z_axis_offset; 27e27c7292SMichael Hennerich 28e27c7292SMichael Hennerich /* 29e27c7292SMichael Hennerich * TAP_X/Y/Z Enable: Setting TAP_X, Y, or Z Enable enables X, 30e27c7292SMichael Hennerich * Y, or Z participation in Tap detection. A '0' excludes the 31e27c7292SMichael Hennerich * selected axis from participation in Tap detection. 32e27c7292SMichael Hennerich * Setting the SUPPRESS bit suppresses Double Tap detection if 33e27c7292SMichael Hennerich * acceleration greater than tap_threshold is present between 34e27c7292SMichael Hennerich * taps. 35e27c7292SMichael Hennerich */ 36e27c7292SMichael Hennerich 37e27c7292SMichael Hennerich #define ADXL_SUPPRESS (1 << 3) 38e27c7292SMichael Hennerich #define ADXL_TAP_X_EN (1 << 2) 39e27c7292SMichael Hennerich #define ADXL_TAP_Y_EN (1 << 1) 40e27c7292SMichael Hennerich #define ADXL_TAP_Z_EN (1 << 0) 41e27c7292SMichael Hennerich 42e27c7292SMichael Hennerich u8 tap_axis_control; 43e27c7292SMichael Hennerich 44e27c7292SMichael Hennerich /* 45e27c7292SMichael Hennerich * tap_threshold: 46e27c7292SMichael Hennerich * holds the threshold value for tap detection/interrupts. 47e27c7292SMichael Hennerich * The data format is unsigned. The scale factor is 62.5 mg/LSB 48e27c7292SMichael Hennerich * (i.e. 0xFF = +16 g). A zero value may result in undesirable 49e27c7292SMichael Hennerich * behavior if Tap/Double Tap is enabled. 50e27c7292SMichael Hennerich */ 51e27c7292SMichael Hennerich 52e27c7292SMichael Hennerich u8 tap_threshold; 53e27c7292SMichael Hennerich 54e27c7292SMichael Hennerich /* 55e27c7292SMichael Hennerich * tap_duration: 56e27c7292SMichael Hennerich * is an unsigned time value representing the maximum 57e27c7292SMichael Hennerich * time that an event must be above the tap_threshold threshold 58e27c7292SMichael Hennerich * to qualify as a tap event. The scale factor is 625 us/LSB. A zero 59e27c7292SMichael Hennerich * value will prevent Tap/Double Tap functions from working. 60e27c7292SMichael Hennerich */ 61e27c7292SMichael Hennerich 62e27c7292SMichael Hennerich u8 tap_duration; 63e27c7292SMichael Hennerich 64e27c7292SMichael Hennerich /* 65e27c7292SMichael Hennerich * tap_latency: 66e27c7292SMichael Hennerich * is an unsigned time value representing the wait time 67e27c7292SMichael Hennerich * from the detection of a tap event to the opening of the time 68e27c7292SMichael Hennerich * window tap_window for a possible second tap event. The scale 69e27c7292SMichael Hennerich * factor is 1.25 ms/LSB. A zero value will disable the Double Tap 70e27c7292SMichael Hennerich * function. 71e27c7292SMichael Hennerich */ 72e27c7292SMichael Hennerich 73e27c7292SMichael Hennerich u8 tap_latency; 74e27c7292SMichael Hennerich 75e27c7292SMichael Hennerich /* 76e27c7292SMichael Hennerich * tap_window: 77e27c7292SMichael Hennerich * is an unsigned time value representing the amount 78e27c7292SMichael Hennerich * of time after the expiration of tap_latency during which a second 79e27c7292SMichael Hennerich * tap can begin. The scale factor is 1.25 ms/LSB. A zero value will 80e27c7292SMichael Hennerich * disable the Double Tap function. 81e27c7292SMichael Hennerich */ 82e27c7292SMichael Hennerich 83e27c7292SMichael Hennerich u8 tap_window; 84e27c7292SMichael Hennerich 85e27c7292SMichael Hennerich /* 86e27c7292SMichael Hennerich * act_axis_control: 87e27c7292SMichael Hennerich * X/Y/Z Enable: A '1' enables X, Y, or Z participation in activity 88e27c7292SMichael Hennerich * or inactivity detection. A '0' excludes the selected axis from 89e27c7292SMichael Hennerich * participation. If all of the axes are excluded, the function is 90e27c7292SMichael Hennerich * disabled. 91e27c7292SMichael Hennerich * AC/DC: A '0' = DC coupled operation and a '1' = AC coupled 92e27c7292SMichael Hennerich * operation. In DC coupled operation, the current acceleration is 93e27c7292SMichael Hennerich * compared with activity_threshold and inactivity_threshold directly 94e27c7292SMichael Hennerich * to determine whether activity or inactivity is detected. In AC 95e27c7292SMichael Hennerich * coupled operation for activity detection, the acceleration value 96e27c7292SMichael Hennerich * at the start of activity detection is taken as a reference value. 97e27c7292SMichael Hennerich * New samples of acceleration are then compared to this 98e27c7292SMichael Hennerich * reference value and if the magnitude of the difference exceeds 99e27c7292SMichael Hennerich * activity_threshold the device will trigger an activity interrupt. In 100e27c7292SMichael Hennerich * AC coupled operation for inactivity detection, a reference value 101e27c7292SMichael Hennerich * is used again for comparison and is updated whenever the 102e27c7292SMichael Hennerich * device exceeds the inactivity threshold. Once the reference 103e27c7292SMichael Hennerich * value is selected, the device compares the magnitude of the 104e27c7292SMichael Hennerich * difference between the reference value and the current 105e27c7292SMichael Hennerich * acceleration with inactivity_threshold. If the difference is below 106e27c7292SMichael Hennerich * inactivity_threshold for a total of inactivity_time, the device is 107e27c7292SMichael Hennerich * considered inactive and the inactivity interrupt is triggered. 108e27c7292SMichael Hennerich */ 109e27c7292SMichael Hennerich 110e27c7292SMichael Hennerich #define ADXL_ACT_ACDC (1 << 7) 111e27c7292SMichael Hennerich #define ADXL_ACT_X_EN (1 << 6) 112e27c7292SMichael Hennerich #define ADXL_ACT_Y_EN (1 << 5) 113e27c7292SMichael Hennerich #define ADXL_ACT_Z_EN (1 << 4) 114e27c7292SMichael Hennerich #define ADXL_INACT_ACDC (1 << 3) 115e27c7292SMichael Hennerich #define ADXL_INACT_X_EN (1 << 2) 116e27c7292SMichael Hennerich #define ADXL_INACT_Y_EN (1 << 1) 117e27c7292SMichael Hennerich #define ADXL_INACT_Z_EN (1 << 0) 118e27c7292SMichael Hennerich 119e27c7292SMichael Hennerich u8 act_axis_control; 120e27c7292SMichael Hennerich 121e27c7292SMichael Hennerich /* 122e27c7292SMichael Hennerich * activity_threshold: 123e27c7292SMichael Hennerich * holds the threshold value for activity detection. 124e27c7292SMichael Hennerich * The data format is unsigned. The scale factor is 125e27c7292SMichael Hennerich * 62.5 mg/LSB. A zero value may result in undesirable behavior if 126e27c7292SMichael Hennerich * Activity interrupt is enabled. 127e27c7292SMichael Hennerich */ 128e27c7292SMichael Hennerich 129e27c7292SMichael Hennerich u8 activity_threshold; 130e27c7292SMichael Hennerich 131e27c7292SMichael Hennerich /* 132e27c7292SMichael Hennerich * inactivity_threshold: 133e27c7292SMichael Hennerich * holds the threshold value for inactivity 134e27c7292SMichael Hennerich * detection. The data format is unsigned. The scale 135e27c7292SMichael Hennerich * factor is 62.5 mg/LSB. A zero value may result in undesirable 136e27c7292SMichael Hennerich * behavior if Inactivity interrupt is enabled. 137e27c7292SMichael Hennerich */ 138e27c7292SMichael Hennerich 139e27c7292SMichael Hennerich u8 inactivity_threshold; 140e27c7292SMichael Hennerich 141e27c7292SMichael Hennerich /* 142e27c7292SMichael Hennerich * inactivity_time: 143e27c7292SMichael Hennerich * is an unsigned time value representing the 144e27c7292SMichael Hennerich * amount of time that acceleration must be below the value in 145e27c7292SMichael Hennerich * inactivity_threshold for inactivity to be declared. The scale factor 146e27c7292SMichael Hennerich * is 1 second/LSB. Unlike the other interrupt functions, which 147e27c7292SMichael Hennerich * operate on unfiltered data, the inactivity function operates on the 148e27c7292SMichael Hennerich * filtered output data. At least one output sample must be 149e27c7292SMichael Hennerich * generated for the inactivity interrupt to be triggered. This will 150e27c7292SMichael Hennerich * result in the function appearing un-responsive if the 151e27c7292SMichael Hennerich * inactivity_time register is set with a value less than the time 152e27c7292SMichael Hennerich * constant of the Output Data Rate. A zero value will result in an 153e27c7292SMichael Hennerich * interrupt when the output data is below inactivity_threshold. 154e27c7292SMichael Hennerich */ 155e27c7292SMichael Hennerich 156e27c7292SMichael Hennerich u8 inactivity_time; 157e27c7292SMichael Hennerich 158e27c7292SMichael Hennerich /* 159e27c7292SMichael Hennerich * free_fall_threshold: 160e27c7292SMichael Hennerich * holds the threshold value for Free-Fall detection. 161e27c7292SMichael Hennerich * The data format is unsigned. The root-sum-square(RSS) value 162e27c7292SMichael Hennerich * of all axes is calculated and compared to the value in 163e27c7292SMichael Hennerich * free_fall_threshold to determine if a free fall event may be 164e27c7292SMichael Hennerich * occurring. The scale factor is 62.5 mg/LSB. A zero value may 165e27c7292SMichael Hennerich * result in undesirable behavior if Free-Fall interrupt is 166e27c7292SMichael Hennerich * enabled. Values between 300 and 600 mg (0x05 to 0x09) are 167e27c7292SMichael Hennerich * recommended. 168e27c7292SMichael Hennerich */ 169e27c7292SMichael Hennerich 170e27c7292SMichael Hennerich u8 free_fall_threshold; 171e27c7292SMichael Hennerich 172e27c7292SMichael Hennerich /* 173e27c7292SMichael Hennerich * free_fall_time: 174e27c7292SMichael Hennerich * is an unsigned time value representing the minimum 175e27c7292SMichael Hennerich * time that the RSS value of all axes must be less than 176e27c7292SMichael Hennerich * free_fall_threshold to generate a Free-Fall interrupt. The 177e27c7292SMichael Hennerich * scale factor is 5 ms/LSB. A zero value may result in 178e27c7292SMichael Hennerich * undesirable behavior if Free-Fall interrupt is enabled. 179e27c7292SMichael Hennerich * Values between 100 to 350 ms (0x14 to 0x46) are recommended. 180e27c7292SMichael Hennerich */ 181e27c7292SMichael Hennerich 182e27c7292SMichael Hennerich u8 free_fall_time; 183e27c7292SMichael Hennerich 184e27c7292SMichael Hennerich /* 185e27c7292SMichael Hennerich * data_rate: 186e27c7292SMichael Hennerich * Selects device bandwidth and output data rate. 187e27c7292SMichael Hennerich * RATE = 3200 Hz / (2^(15 - x)). Default value is 0x0A, or 100 Hz 188e27c7292SMichael Hennerich * Output Data Rate. An Output Data Rate should be selected that 189e27c7292SMichael Hennerich * is appropriate for the communication protocol and frequency 190e27c7292SMichael Hennerich * selected. Selecting too high of an Output Data Rate with a low 191e27c7292SMichael Hennerich * communication speed will result in samples being discarded. 192e27c7292SMichael Hennerich */ 193e27c7292SMichael Hennerich 194e27c7292SMichael Hennerich u8 data_rate; 195e27c7292SMichael Hennerich 196e27c7292SMichael Hennerich /* 197e27c7292SMichael Hennerich * data_range: 198e27c7292SMichael Hennerich * FULL_RES: When this bit is set with the device is 199e27c7292SMichael Hennerich * in Full-Resolution Mode, where the output resolution increases 200e27c7292SMichael Hennerich * with RANGE to maintain a 4 mg/LSB scale factor. When this 201e27c7292SMichael Hennerich * bit is cleared the device is in 10-bit Mode and RANGE determine the 202e27c7292SMichael Hennerich * maximum g-Range and scale factor. 203e27c7292SMichael Hennerich */ 204e27c7292SMichael Hennerich 205e27c7292SMichael Hennerich #define ADXL_FULL_RES (1 << 3) 206e27c7292SMichael Hennerich #define ADXL_RANGE_PM_2g 0 207e27c7292SMichael Hennerich #define ADXL_RANGE_PM_4g 1 208e27c7292SMichael Hennerich #define ADXL_RANGE_PM_8g 2 209e27c7292SMichael Hennerich #define ADXL_RANGE_PM_16g 3 210e27c7292SMichael Hennerich 211e27c7292SMichael Hennerich u8 data_range; 212e27c7292SMichael Hennerich 213e27c7292SMichael Hennerich /* 214e27c7292SMichael Hennerich * low_power_mode: 215e27c7292SMichael Hennerich * A '0' = Normal operation and a '1' = Reduced 216e27c7292SMichael Hennerich * power operation with somewhat higher noise. 217e27c7292SMichael Hennerich */ 218e27c7292SMichael Hennerich 219e27c7292SMichael Hennerich u8 low_power_mode; 220e27c7292SMichael Hennerich 221e27c7292SMichael Hennerich /* 222e27c7292SMichael Hennerich * power_mode: 223e27c7292SMichael Hennerich * LINK: A '1' with both the activity and inactivity functions 224e27c7292SMichael Hennerich * enabled will delay the start of the activity function until 225e27c7292SMichael Hennerich * inactivity is detected. Once activity is detected, inactivity 226e27c7292SMichael Hennerich * detection will begin and prevent the detection of activity. This 227e27c7292SMichael Hennerich * bit serially links the activity and inactivity functions. When '0' 228e27c7292SMichael Hennerich * the inactivity and activity functions are concurrent. Additional 229e27c7292SMichael Hennerich * information can be found in the Application section under Link 230e27c7292SMichael Hennerich * Mode. 231e27c7292SMichael Hennerich * AUTO_SLEEP: A '1' sets the ADXL34x to switch to Sleep Mode 232e27c7292SMichael Hennerich * when inactivity (acceleration has been below inactivity_threshold 233e27c7292SMichael Hennerich * for at least inactivity_time) is detected and the LINK bit is set. 234e27c7292SMichael Hennerich * A '0' disables automatic switching to Sleep Mode. See SLEEP 235e27c7292SMichael Hennerich * for further description. 236e27c7292SMichael Hennerich */ 237e27c7292SMichael Hennerich 238e27c7292SMichael Hennerich #define ADXL_LINK (1 << 5) 239e27c7292SMichael Hennerich #define ADXL_AUTO_SLEEP (1 << 4) 240e27c7292SMichael Hennerich 241e27c7292SMichael Hennerich u8 power_mode; 242e27c7292SMichael Hennerich 243e27c7292SMichael Hennerich /* 244e27c7292SMichael Hennerich * fifo_mode: 245e27c7292SMichael Hennerich * BYPASS The FIFO is bypassed 246e27c7292SMichael Hennerich * FIFO FIFO collects up to 32 values then stops collecting data 247e27c7292SMichael Hennerich * STREAM FIFO holds the last 32 data values. Once full, the FIFO's 248e27c7292SMichael Hennerich * oldest data is lost as it is replaced with newer data 249e27c7292SMichael Hennerich * 250e27c7292SMichael Hennerich * DEFAULT should be ADXL_FIFO_STREAM 251e27c7292SMichael Hennerich */ 252e27c7292SMichael Hennerich 253e27c7292SMichael Hennerich #define ADXL_FIFO_BYPASS 0 254e27c7292SMichael Hennerich #define ADXL_FIFO_FIFO 1 255e27c7292SMichael Hennerich #define ADXL_FIFO_STREAM 2 256e27c7292SMichael Hennerich 257e27c7292SMichael Hennerich u8 fifo_mode; 258e27c7292SMichael Hennerich 259e27c7292SMichael Hennerich /* 260e27c7292SMichael Hennerich * watermark: 261e27c7292SMichael Hennerich * The Watermark feature can be used to reduce the interrupt load 262e27c7292SMichael Hennerich * of the system. The FIFO fills up to the value stored in watermark 263e27c7292SMichael Hennerich * [1..32] and then generates an interrupt. 264e27c7292SMichael Hennerich * A '0' disables the watermark feature. 265e27c7292SMichael Hennerich */ 266e27c7292SMichael Hennerich 267e27c7292SMichael Hennerich u8 watermark; 268e27c7292SMichael Hennerich 269e27c7292SMichael Hennerich u32 ev_type; /* EV_ABS or EV_REL */ 270e27c7292SMichael Hennerich 271e27c7292SMichael Hennerich u32 ev_code_x; /* ABS_X,Y,Z or REL_X,Y,Z */ 272e27c7292SMichael Hennerich u32 ev_code_y; /* ABS_X,Y,Z or REL_X,Y,Z */ 273e27c7292SMichael Hennerich u32 ev_code_z; /* ABS_X,Y,Z or REL_X,Y,Z */ 274e27c7292SMichael Hennerich 275e27c7292SMichael Hennerich /* 276e27c7292SMichael Hennerich * A valid BTN or KEY Code; use tap_axis_control to disable 277e27c7292SMichael Hennerich * event reporting 278e27c7292SMichael Hennerich */ 279e27c7292SMichael Hennerich 280e27c7292SMichael Hennerich u32 ev_code_tap[3]; /* EV_KEY {X-Axis, Y-Axis, Z-Axis} */ 281e27c7292SMichael Hennerich 282e27c7292SMichael Hennerich /* 283e27c7292SMichael Hennerich * A valid BTN or KEY Code for Free-Fall or Activity enables 284e27c7292SMichael Hennerich * input event reporting. A '0' disables the Free-Fall or 285e27c7292SMichael Hennerich * Activity reporting. 286e27c7292SMichael Hennerich */ 287e27c7292SMichael Hennerich 288e27c7292SMichael Hennerich u32 ev_code_ff; /* EV_KEY */ 289e27c7292SMichael Hennerich u32 ev_code_act_inactivity; /* EV_KEY */ 290e27c7292SMichael Hennerich 291e27c7292SMichael Hennerich u8 use_int2; 292e27c7292SMichael Hennerich }; 293e27c7292SMichael Hennerich #endif 294