mma9551_core.h (2608B)
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Common code for Freescale MMA955x Intelligent Sensor Platform drivers 4 * Copyright (c) 2014, Intel Corporation. 5 */ 6 7#ifndef _MMA9551_CORE_H_ 8#define _MMA9551_CORE_H_ 9 10/* Applications IDs */ 11#define MMA9551_APPID_VERSION 0x00 12#define MMA9551_APPID_GPIO 0x03 13#define MMA9551_APPID_AFE 0x06 14#define MMA9551_APPID_TILT 0x0B 15#define MMA9551_APPID_SLEEP_WAKE 0x12 16#define MMA9551_APPID_PEDOMETER 0x15 17#define MMA9551_APPID_RSC 0x17 18#define MMA9551_APPID_NONE 0xff 19 20/* Reset/Suspend/Clear application app masks */ 21#define MMA9551_RSC_PED BIT(21) 22 23#define MMA9551_AUTO_SUSPEND_DELAY_MS 2000 24 25enum mma9551_gpio_pin { 26 mma9551_gpio6 = 0, 27 mma9551_gpio7, 28 mma9551_gpio8, 29 mma9551_gpio9, 30 mma9551_gpio_max = mma9551_gpio9, 31}; 32 33#define MMA9551_ACCEL_CHANNEL(axis) { \ 34 .type = IIO_ACCEL, \ 35 .modified = 1, \ 36 .channel2 = axis, \ 37 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 38 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ 39} 40 41int mma9551_read_config_byte(struct i2c_client *client, u8 app_id, 42 u16 reg, u8 *val); 43int mma9551_write_config_byte(struct i2c_client *client, u8 app_id, 44 u16 reg, u8 val); 45int mma9551_read_status_byte(struct i2c_client *client, u8 app_id, 46 u16 reg, u8 *val); 47int mma9551_read_config_word(struct i2c_client *client, u8 app_id, 48 u16 reg, u16 *val); 49int mma9551_write_config_word(struct i2c_client *client, u8 app_id, 50 u16 reg, u16 val); 51int mma9551_read_status_word(struct i2c_client *client, u8 app_id, 52 u16 reg, u16 *val); 53int mma9551_read_config_words(struct i2c_client *client, u8 app_id, 54 u16 reg, u8 len, u16 *buf); 55int mma9551_read_status_words(struct i2c_client *client, u8 app_id, 56 u16 reg, u8 len, u16 *buf); 57int mma9551_write_config_words(struct i2c_client *client, u8 app_id, 58 u16 reg, u8 len, u16 *buf); 59int mma9551_update_config_bits(struct i2c_client *client, u8 app_id, 60 u16 reg, u8 mask, u8 val); 61int mma9551_gpio_config(struct i2c_client *client, enum mma9551_gpio_pin pin, 62 u8 app_id, u8 bitnum, int polarity); 63int mma9551_read_version(struct i2c_client *client); 64int mma9551_set_device_state(struct i2c_client *client, bool enable); 65int mma9551_set_power_state(struct i2c_client *client, bool on); 66void mma9551_sleep(int freq); 67int mma9551_read_accel_chan(struct i2c_client *client, 68 const struct iio_chan_spec *chan, 69 int *val, int *val2); 70int mma9551_read_accel_scale(int *val, int *val2); 71int mma9551_app_reset(struct i2c_client *client, u32 app_mask); 72 73#endif /* _MMA9551_CORE_H_ */