Merge branch 'pm-cpufreq'
[linux-2.6-block.git] / drivers / iio / accel / mma9551_core.h
CommitLineData
d5b97f5c
IT
1/*
2 * Common code for Freescale MMA955x Intelligent Sensor Platform drivers
3 * Copyright (c) 2014, Intel Corporation.
4 *
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.
8 *
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
12 * more details.
13 */
14
15#ifndef _MMA9551_CORE_H_
16#define _MMA9551_CORE_H_
17
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
40cb7613 24#define MMA9551_APPID_PEDOMETER 0x15
476c41a7 25#define MMA9551_APPID_RSC 0x17
d5b97f5c
IT
26#define MMA9551_APPID_NONE 0xff
27
40cb7613
IT
28/* Reset/Suspend/Clear application app masks */
29#define MMA9551_RSC_PED BIT(21)
30
d5b97f5c
IT
31#define MMA9551_AUTO_SUSPEND_DELAY_MS 2000
32
33enum mma9551_gpio_pin {
34 mma9551_gpio6 = 0,
35 mma9551_gpio7,
36 mma9551_gpio8,
37 mma9551_gpio9,
38 mma9551_gpio_max = mma9551_gpio9,
39};
40
41#define MMA9551_ACCEL_CHANNEL(axis) { \
42 .type = IIO_ACCEL, \
43 .modified = 1, \
44 .channel2 = axis, \
45 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
46 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
47}
48
49int mma9551_read_config_byte(struct i2c_client *client, u8 app_id,
50 u16 reg, u8 *val);
51int mma9551_write_config_byte(struct i2c_client *client, u8 app_id,
52 u16 reg, u8 val);
53int mma9551_read_status_byte(struct i2c_client *client, u8 app_id,
54 u16 reg, u8 *val);
40cb7613 55int mma9551_read_config_word(struct i2c_client *client, u8 app_id,
b37c1990 56 u16 reg, u16 *val);
40cb7613 57int mma9551_write_config_word(struct i2c_client *client, u8 app_id,
b37c1990 58 u16 reg, u16 val);
d5b97f5c
IT
59int mma9551_read_status_word(struct i2c_client *client, u8 app_id,
60 u16 reg, u16 *val);
40cb7613 61int mma9551_read_config_words(struct i2c_client *client, u8 app_id,
b37c1990 62 u16 reg, u8 len, u16 *buf);
40cb7613
IT
63int mma9551_read_status_words(struct i2c_client *client, u8 app_id,
64 u16 reg, u8 len, u16 *buf);
65int mma9551_write_config_words(struct i2c_client *client, u8 app_id,
66 u16 reg, u8 len, u16 *buf);
d5b97f5c
IT
67int mma9551_update_config_bits(struct i2c_client *client, u8 app_id,
68 u16 reg, u8 mask, u8 val);
69int mma9551_gpio_config(struct i2c_client *client, enum mma9551_gpio_pin pin,
70 u8 app_id, u8 bitnum, int polarity);
71int mma9551_read_version(struct i2c_client *client);
72int mma9551_set_device_state(struct i2c_client *client, bool enable);
73int mma9551_set_power_state(struct i2c_client *client, bool on);
74void mma9551_sleep(int freq);
75int mma9551_read_accel_chan(struct i2c_client *client,
76 const struct iio_chan_spec *chan,
77 int *val, int *val2);
78int mma9551_read_accel_scale(int *val, int *val2);
40cb7613 79int mma9551_app_reset(struct i2c_client *client, u32 app_mask);
d5b97f5c
IT
80
81#endif /* _MMA9551_CORE_H_ */