mma9551_core.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #ifndef _MMA9551_CORE_H_
  7. #define _MMA9551_CORE_H_
  8. /* Applications IDs */
  9. #define MMA9551_APPID_VERSION 0x00
  10. #define MMA9551_APPID_GPIO 0x03
  11. #define MMA9551_APPID_AFE 0x06
  12. #define MMA9551_APPID_TILT 0x0B
  13. #define MMA9551_APPID_SLEEP_WAKE 0x12
  14. #define MMA9551_APPID_PEDOMETER 0x15
  15. #define MMA9551_APPID_RSC 0x17
  16. #define MMA9551_APPID_NONE 0xff
  17. /* Reset/Suspend/Clear application app masks */
  18. #define MMA9551_RSC_PED BIT(21)
  19. #define MMA9551_AUTO_SUSPEND_DELAY_MS 2000
  20. enum mma9551_gpio_pin {
  21. mma9551_gpio6 = 0,
  22. mma9551_gpio7,
  23. mma9551_gpio8,
  24. mma9551_gpio9,
  25. mma9551_gpio_max = mma9551_gpio9,
  26. };
  27. #define MMA9551_ACCEL_CHANNEL(axis) { \
  28. .type = IIO_ACCEL, \
  29. .modified = 1, \
  30. .channel2 = axis, \
  31. .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
  32. .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
  33. }
  34. int mma9551_read_config_byte(struct i2c_client *client, u8 app_id,
  35. u16 reg, u8 *val);
  36. int mma9551_write_config_byte(struct i2c_client *client, u8 app_id,
  37. u16 reg, u8 val);
  38. int mma9551_read_status_byte(struct i2c_client *client, u8 app_id,
  39. u16 reg, u8 *val);
  40. int mma9551_read_config_word(struct i2c_client *client, u8 app_id,
  41. u16 reg, u16 *val);
  42. int mma9551_write_config_word(struct i2c_client *client, u8 app_id,
  43. u16 reg, u16 val);
  44. int mma9551_read_status_word(struct i2c_client *client, u8 app_id,
  45. u16 reg, u16 *val);
  46. int mma9551_read_config_words(struct i2c_client *client, u8 app_id,
  47. u16 reg, u8 len, u16 *buf);
  48. int mma9551_read_status_words(struct i2c_client *client, u8 app_id,
  49. u16 reg, u8 len, u16 *buf);
  50. int mma9551_write_config_words(struct i2c_client *client, u8 app_id,
  51. u16 reg, u8 len, u16 *buf);
  52. int mma9551_update_config_bits(struct i2c_client *client, u8 app_id,
  53. u16 reg, u8 mask, u8 val);
  54. int mma9551_gpio_config(struct i2c_client *client, enum mma9551_gpio_pin pin,
  55. u8 app_id, u8 bitnum, int polarity);
  56. int mma9551_read_version(struct i2c_client *client);
  57. int mma9551_set_device_state(struct i2c_client *client, bool enable);
  58. int mma9551_set_power_state(struct i2c_client *client, bool on);
  59. void mma9551_sleep(int freq);
  60. int mma9551_read_accel_chan(struct i2c_client *client,
  61. const struct iio_chan_spec *chan,
  62. int *val, int *val2);
  63. int mma9551_read_accel_scale(int *val, int *val2);
  64. int mma9551_app_reset(struct i2c_client *client, u32 app_mask);
  65. #endif /* _MMA9551_CORE_H_ */