2 * Common code for Freescale MMA955x Intelligent Sensor Platform drivers
3 * Copyright (c) 2014, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 #ifndef _MMA9551_CORE_H_
16 #define _MMA9551_CORE_H_
18 /* Applications IDs */
19 #define MMA9551_APPID_VERSION 0x00
20 #define MMA9551_APPID_GPIO 0x03
21 #define MMA9551_APPID_AFE 0x06
22 #define MMA9551_APPID_TILT 0x0B
23 #define MMA9551_APPID_SLEEP_WAKE 0x12
24 #define MMA9551_APPID_PEDOMETER 0x15
25 #define MMA9551_APPID_RSC 0x17
26 #define MMA9551_APPID_NONE 0xff
28 /* Reset/Suspend/Clear application app masks */
29 #define MMA9551_RSC_PED BIT(21)
31 #define MMA9551_AUTO_SUSPEND_DELAY_MS 2000
33 enum mma9551_gpio_pin
{
38 mma9551_gpio_max
= mma9551_gpio9
,
41 #define MMA9551_ACCEL_CHANNEL(axis) { \
45 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
46 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
49 int mma9551_read_config_byte(struct i2c_client
*client
, u8 app_id
,
51 int mma9551_write_config_byte(struct i2c_client
*client
, u8 app_id
,
53 int mma9551_read_status_byte(struct i2c_client
*client
, u8 app_id
,
55 int mma9551_read_config_word(struct i2c_client
*client
, u8 app_id
,
57 int mma9551_write_config_word(struct i2c_client
*client
, u8 app_id
,
59 int mma9551_read_status_word(struct i2c_client
*client
, u8 app_id
,
61 int mma9551_read_config_words(struct i2c_client
*client
, u8 app_id
,
62 u16 reg
, u8 len
, u16
*buf
);
63 int mma9551_read_status_words(struct i2c_client
*client
, u8 app_id
,
64 u16 reg
, u8 len
, u16
*buf
);
65 int mma9551_write_config_words(struct i2c_client
*client
, u8 app_id
,
66 u16 reg
, u8 len
, u16
*buf
);
67 int mma9551_update_config_bits(struct i2c_client
*client
, u8 app_id
,
68 u16 reg
, u8 mask
, u8 val
);
69 int mma9551_gpio_config(struct i2c_client
*client
, enum mma9551_gpio_pin pin
,
70 u8 app_id
, u8 bitnum
, int polarity
);
71 int mma9551_read_version(struct i2c_client
*client
);
72 int mma9551_set_device_state(struct i2c_client
*client
, bool enable
);
73 int mma9551_set_power_state(struct i2c_client
*client
, bool on
);
74 void mma9551_sleep(int freq
);
75 int mma9551_read_accel_chan(struct i2c_client
*client
,
76 const struct iio_chan_spec
*chan
,
78 int mma9551_read_accel_scale(int *val
, int *val2
);
79 int mma9551_app_reset(struct i2c_client
*client
, u32 app_mask
);
81 #endif /* _MMA9551_CORE_H_ */