bmg160_reg.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright (C) 2013 Samsung Electronics. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  16. * 02110-1301 USA
  17. */
  18. #ifndef _BMG160_REG_H_
  19. #define _BMG160_REG_H_
  20. /* For Settings */
  21. #define BMG160_MODE_NORMAL 0
  22. #define BMG160_MODE_DEEPSUSPEND 1
  23. #define BMG160_MODE_SUSPEND 2
  24. #define BMG160_MODE_FASTPOWERUP 3
  25. #define BMG160_MODE_ADVANCEDPOWERSAVING 4
  26. #define BMG160_RANGE_2000DPS 0
  27. #define BMG160_RANGE_1000DPS 1
  28. #define BMG160_RANGE_500DPS 2
  29. #define BMG160_RANGE_250DPS 3
  30. #define BMG160_RANGE_125DPS 4
  31. #define BMG160_No_Filter 0
  32. #define BMG160_BW_230Hz 1
  33. #define BMG160_BW_116Hz 2
  34. #define BMG160_BW_47Hz 3
  35. #define BMG160_BW_23Hz 4
  36. #define BMG160_BW_12Hz 5
  37. #define BMG160_BW_64Hz 6
  38. #define BMG160_BW_32Hz 7
  39. #define BMG160_No_AutoSleepDur 0
  40. #define BMG160_4ms_AutoSleepDur 1
  41. #define BMG160_5ms_AutoSleepDur 2
  42. #define BMG160_8ms_AutoSleepDur 3
  43. #define BMG160_10ms_AutoSleepDur 4
  44. #define BMG160_15ms_AutoSleepDur 5
  45. #define BMG160_20ms_AutoSleepDur 6
  46. #define BMG160_40ms_AutoSleepDur 7
  47. /* Data Register */
  48. #define BMG160_CHIP_ID_REG 0x00
  49. #ifdef CONFIG_SENSORS_BMI058
  50. #define BMG160_RATE_X_LSB_ADDR 0x04
  51. #define BMG160_RATE_X_MSB_ADDR 0x05
  52. #define BMG160_RATE_Y_LSB_ADDR 0x02
  53. #define BMG160_RATE_Y_MSB_ADDR 0x03
  54. #else
  55. #define BMG160_RATE_X_LSB_ADDR 0x02
  56. #define BMG160_RATE_X_MSB_ADDR 0x03
  57. #define BMG160_RATE_Y_LSB_ADDR 0x04
  58. #define BMG160_RATE_Y_MSB_ADDR 0x05
  59. #endif
  60. #define BMG160_RATE_Z_LSB_ADDR 0x06
  61. #define BMG160_RATE_Z_MSB_ADDR 0x07
  62. #define BMG160_TEMP_ADDR 0x08
  63. /* Control Register */
  64. #define BMG160_RANGE_ADDR 0x0F
  65. #define BMG160_BW_ADDR 0x10
  66. #define BMG160_MODE_LPM1_ADDR 0x11
  67. #define BMG160_MODE_LPM2_ADDR 0x12
  68. #define BMG160_RATED_HBW_ADDR 0x13
  69. #define BMG160_BGW_SOFTRESET_ADDR 0x14
  70. #define BMG160_SELF_TEST_ADDR 0x3C
  71. #define BMG160_RATE_X_LSB_VALUEX__POS 0
  72. #define BMG160_RATE_X_LSB_VALUEX__LEN 8
  73. #define BMG160_RATE_X_LSB_VALUEX__MSK 0xFF
  74. #define BMG160_RATE_X_LSB_VALUEX__REG BMG160_RATE_X_LSB_ADDR
  75. #define BMG160_RATE_Y_LSB_VALUEY__POS 0
  76. #define BMG160_RATE_Y_LSB_VALUEY__LEN 8
  77. #define BMG160_RATE_Y_LSB_VALUEY__MSK 0xFF
  78. #define BMG160_RATE_Y_LSB_VALUEY__REG BMG160_RATE_Y_LSB_ADDR
  79. #define BMG160_RATE_Z_LSB_VALUEZ__POS 0
  80. #define BMG160_RATE_Z_LSB_VALUEZ__LEN 8
  81. #define BMG160_RATE_Z_LSB_VALUEZ__MSK 0xFF
  82. #define BMG160_RATE_Z_LSB_VALUEZ__REG BMG160_RATE_Z_LSB_ADDR
  83. #define BMG160_MODE_LPM1__POS 5
  84. #define BMG160_MODE_LPM1__LEN 3
  85. #define BMG160_MODE_LPM1__MSK 0xA0
  86. #define BMG160_MODE_LPM1__REG BMG160_MODE_LPM1_ADDR
  87. #define BMG160_MODELPM1_ADDR_SLEEPDUR__POS 1
  88. #define BMG160_MODELPM1_ADDR_SLEEPDUR__LEN 3
  89. #define BMG160_MODELPM1_ADDR_SLEEPDUR__MSK 0x0E
  90. #define BMG160_MODELPM1_ADDR_SLEEPDUR__REG BMG160_MODE_LPM1_ADDR
  91. #define BMG160_MODE_LPM2_ADDR_FAST_POWERUP__POS 7
  92. #define BMG160_MODE_LPM2_ADDR_FAST_POWERUP__LEN 1
  93. #define BMG160_MODE_LPM2_ADDR_FAST_POWERUP__MSK 0x80
  94. #define BMG160_MODE_LPM2_ADDR_FAST_POWERUP__REG BMG160_MODE_LPM2_ADDR
  95. #define BMG160_MODE_LPM2_ADDR_ADV_POWERSAVING__POS 6
  96. #define BMG160_MODE_LPM2_ADDR_ADV_POWERSAVING__LEN 1
  97. #define BMG160_MODE_LPM2_ADDR_ADV_POWERSAVING__MSK 0x40
  98. #define BMG160_MODE_LPM2_ADDR_ADV_POWERSAVING__REG BMG160_MODE_LPM2_ADDR
  99. #define BMG160_MODE_LPM2_ADDR_EXT_TRI_SEL__POS 4
  100. #define BMG160_MODE_LPM2_ADDR_EXT_TRI_SEL__LEN 2
  101. #define BMG160_MODE_LPM2_ADDR_EXT_TRI_SEL__MSK 0x30
  102. #define BMG160_MODE_LPM2_ADDR_EXT_TRI_SEL__REG BMG160_MODE_LPM2_ADDR
  103. #define BMG160_MODE_LPM2_ADDR_AUTOSLEEPDUR__POS 0
  104. #define BMG160_MODE_LPM2_ADDR_AUTOSLEEPDUR__LEN 3
  105. #define BMG160_MODE_LPM2_ADDR_AUTOSLEEPDUR__MSK 0x07
  106. #define BMG160_MODE_LPM2_ADDR_AUTOSLEEPDUR__REG BMG160_MODE_LPM2_ADDR
  107. #define BMG160_RANGE_ADDR_RANGE__POS 0
  108. #define BMG160_RANGE_ADDR_RANGE__LEN 3
  109. #define BMG160_RANGE_ADDR_RANGE__MSK 0x07
  110. #define BMG160_RANGE_ADDR_RANGE__REG BMG160_RANGE_ADDR
  111. #define BMG160_BW_ADDR__POS 0
  112. #define BMG160_BW_ADDR__LEN 3
  113. #define BMG160_BW_ADDR__MSK 0x07
  114. #define BMG160_BW_ADDR__REG BMG160_BW_ADDR
  115. #define BMG160_SELF_TEST_ADDR_BISTFAIL__POS 2
  116. #define BMG160_SELF_TEST_ADDR_BISTFAIL__LEN 1
  117. #define BMG160_SELF_TEST_ADDR_BISTFAIL__MSK 0x04
  118. #define BMG160_SELF_TEST_ADDR_BISTFAIL__REG BMG160_SELF_TEST_ADDR
  119. #define BMG160_SELF_TEST_ADDR_TRIGBIST__POS 0
  120. #define BMG160_SELF_TEST_ADDR_TRIGBIST__LEN 1
  121. #define BMG160_SELF_TEST_ADDR_TRIGBIST__MSK 0x01
  122. #define BMG160_SELF_TEST_ADDR_TRIGBIST__REG BMG160_SELF_TEST_ADDR
  123. #define BMG160_SELF_TEST_ADDR_RATEOK__POS 4
  124. #define BMG160_SELF_TEST_ADDR_RATEOK__LEN 1
  125. #define BMG160_SELF_TEST_ADDR_RATEOK__MSK 0x10
  126. #define BMG160_SELF_TEST_ADDR_RATEOK__REG BMG160_SELF_TEST_ADDR
  127. /* get bit slice */
  128. #define BMG160_GET_BITSLICE(regvar, bitname)\
  129. ((regvar & bitname##__MSK) >> bitname##__POS)
  130. /* Set bit slice */
  131. #define BMG160_SET_BITSLICE(regvar, bitname, val)\
  132. ((regvar & ~bitname##__MSK) |\
  133. ((val << bitname##__POS) & bitname##__MSK))
  134. enum {
  135. OFF = 0,
  136. ON = 1
  137. };
  138. #endif