File size: 3,689 Bytes
04c0823 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | /* Copyright (C) 2014 STMicroelectronics
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* File Name : ais328dq.h
* Authors : VMA - Volume Mems & Analog Division
* : Matteo Dameno (matteo.dameno@st.com)
* : Author is willing to be considered the contact
* : and update point for the driver.
* Version : V 1.0.1
* Date : 2012/10/07
* Description : AIS328DQ 3D accelerometer sensor LDD
*
*/
#ifndef __AIS328DQ_H__
#define __AIS328DQ_H__
#define AIS328DQ_ACC_I2C_SAD_L (0x18)
#define AIS328DQ_ACC_I2C_SAD_H (0x19)
#define AIS328DQ_ACC_DEV_NAME "ais328dq_acc"
/************************************************/
/* Accelerometer section defines */
/************************************************/
/* Accelerometer Sensor Full Scale */
#define AIS328DQ_ACC_FS_MASK 0x30
#define AIS328DQ_ACC_G_2G 0x00
#define AIS328DQ_ACC_G_4G 0x10
#define AIS328DQ_ACC_G_8G 0x30
/* Accelerometer Sensor Operating Mode */
#define AIS328DQ_ACC_ENABLE 0x01
#define AIS328DQ_ACC_DISABLE 0x00
#define AIS328DQ_ACC_PM_NORMAL 0x20
#define AIS328DQ_ACC_PM_OFF AIS328DQ_ACC_DISABLE
#ifdef __KERNEL__
#if defined(CONFIG_INPUT_AIS328DQ_SPI) || \
defined(CONFIG_INPUT_AIS328DQ_SPI_MODULE)
#define AIS328DQ_RX_MAX_LENGTH 500
#define AIS328DQ_TX_MAX_LENGTH 500
struct ais328dq_transfer_buffer {
u8 rx_buf[AIS328DQ_RX_MAX_LENGTH];
u8 tx_buf[AIS328DQ_TX_MAX_LENGTH] ____cacheline_aligned;
};
#endif
struct ais328dq_transfer_function {
int (*write)(struct device *dev, u8 reg_addr, int len, u8 *data);
int (*read)(struct device *dev, u8 addr, int len, u8 *data);
};
struct ais328dq_acc_platform_data {
int poll_interval;
int min_interval;
u8 g_range;
u8 axis_map_x;
u8 axis_map_y;
u8 axis_map_z;
u8 negate_x;
u8 negate_y;
u8 negate_z;
int (*init)(void);
void (*exit)(void);
int (*power_on)(void);
int (*power_off)(void);
/* set gpio_int[1,2] either to the choosen gpio pin number or to -EINVAL
* if leaved unconnected
*/
int gpio_int1;
int gpio_int2;
};
#define RESUME_ENTRIES 12
struct ais328dq_acc_data {
const char *name;
struct device *dev;
u16 bus_type;
struct ais328dq_acc_platform_data *pdata;
struct mutex lock;
s64 timestamp, delta_ts;
struct hrtimer hr_timer;
struct workqueue_struct *work_queue;
struct work_struct poll_work;
struct input_dev *input_dev;
int hw_initialized;
/* hw_working=-1 means not tested yet */
int hw_working;
int selftest_enabled;
atomic_t enabled;
u8 sensitivity;
u8 resume_state[RESUME_ENTRIES];
int irq1;
struct work_struct irq1_work;
struct workqueue_struct *irq1_work_queue;
int irq2;
struct work_struct irq2_work;
struct workqueue_struct *irq2_work_queue;
#ifdef AIS328DQ_DEBUG
u8 reg_addr;
#endif
#if defined(CONFIG_INPUT_AIS328DQ_SPI) || \
defined(CONFIG_INPUT_AIS328DQ_SPI_MODULE)
struct ais328dq_transfer_buffer tb;
#endif
struct ais328dq_transfer_function *tf;
};
int ais328dq_acc_probe(struct ais328dq_acc_data *acc);
int ais328dq_acc_remove(struct ais328dq_acc_data *acc);
int ais328dq_acc_enable(struct ais328dq_acc_data *acc);
int ais328dq_acc_disable(struct ais328dq_acc_data *acc);
#endif /* __KERNEL__ */
#endif /* __AIS328DQ_H__ */
|