kxtj2_1009.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* linux/drivers/hwmon/adxl345.c
  2. *
  3. * (C) Copyright 2008
  4. * MediaTek <www.mediatek.com>
  5. *
  6. * KXTJ2_1009 driver for MT6575
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA KXTIK
  21. */
  22. #ifndef KXTJ2_1009_H
  23. #define KXTJ2_1009_H
  24. #include <linux/ioctl.h>
  25. #define KXTJ2_1009_I2C_SLAVE_ADDR 0x1C
  26. /* KXTJ2_1009 Register Map (Please refer to KXTJ2_1009 Specifications) */
  27. #define KXTJ2_1009_REG_DEVID 0x0F
  28. #define KXTJ2_1009_REG_BW_RATE 0x21
  29. #define KXTJ2_1009_REG_POWER_CTL 0x1B
  30. #define KXTJ2_1009_REG_CTL_REG3 0x1D
  31. #define KXTJ2_1009_DCST_RESP 0x0C
  32. #define KXTJ2_1009_REG_DATA_FORMAT 0x1B
  33. #define KXTJ2_1009_REG_DATA_RESOLUTION 0x1B
  34. #define KXTJ2_1009_RANGE_DATA_RESOLUTION_MASK 0x40
  35. #define KXTJ2_1009_REG_DATAX0 0x06
  36. #define KXTJ2_1009_FIXED_DEVID 0x09
  37. #define KXTJ2_1009_BW_200HZ 0x05
  38. #define KXTJ2_1009_BW_100HZ 0x04
  39. #define KXTJ2_1009_BW_50HZ 0x03
  40. #define KXTJ2_1009_MEASURE_MODE 0x80
  41. #define KXTJ2_1009_RANGE_MASK 0x18
  42. #define KXTJ2_1009_RANGE_2G 0x00
  43. #define KXTJ2_1009_RANGE_4G 0x08
  44. #define KXTJ2_1009_RANGE_8G 0x10
  45. #define KXTJ2_1009_REG_INT_ENABLE 0x1E
  46. #define KXTJ2_1009_SELF_TEST 0x10
  47. #define KXTJ2_1009_SUCCESS 0
  48. #define KXTJ2_1009_ERR_I2C -1
  49. #define KXTJ2_1009_ERR_STATUS -3
  50. #define KXTJ2_1009_ERR_SETUP_FAILURE -4
  51. #define KXTJ2_1009_ERR_GETGSENSORDATA -5
  52. #define KXTJ2_1009_ERR_IDENTIFICATION -6
  53. #define KXTJ2_1009_BUFSIZE 256
  54. #define KXTJ2_1009_AXES_NUM 3
  55. /*----------------------------------------------------------------------------*/
  56. typedef enum{
  57. KXTJ2_1009_CUST_ACTION_SET_CUST = 1,
  58. KXTJ2_1009_CUST_ACTION_SET_CALI,
  59. KXTJ2_1009_CUST_ACTION_RESET_CALI
  60. }CUST_ACTION;
  61. /*----------------------------------------------------------------------------*/
  62. typedef struct
  63. {
  64. uint16_t action;
  65. }KXTJ2_1009_CUST;
  66. /*----------------------------------------------------------------------------*/
  67. typedef struct
  68. {
  69. uint16_t action;
  70. uint16_t part;
  71. int32_t data[0];
  72. }KXTJ2_1009_SET_CUST;
  73. /*----------------------------------------------------------------------------*/
  74. typedef struct
  75. {
  76. uint16_t action;
  77. int32_t data[KXTJ2_1009_AXES_NUM];
  78. }KXTJ2_1009_SET_CALI;
  79. /*----------------------------------------------------------------------------*/
  80. typedef KXTJ2_1009_CUST KXTJ2_1009_RESET_CALI;
  81. /*----------------------------------------------------------------------------*/
  82. typedef union
  83. {
  84. uint32_t data[10];
  85. KXTJ2_1009_CUST cust;
  86. KXTJ2_1009_SET_CUST setCust;
  87. KXTJ2_1009_SET_CALI setCali;
  88. KXTJ2_1009_RESET_CALI resetCali;
  89. }KXTJ2_1009_CUST_DATA;
  90. /*----------------------------------------------------------------------------*/
  91. #endif