mma9551_core.h 2.9 KB

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