bma150.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. /*
  2. * Copyright (c) 2011 Bosch Sensortec GmbH
  3. * Copyright (c) 2011 Unixphere
  4. *
  5. * This driver adds support for Bosch Sensortec's digital acceleration
  6. * sensors BMA150 and SMB380.
  7. * The SMB380 is fully compatible with BMA150 and only differs in packaging.
  8. *
  9. * The datasheet for the BMA150 chip can be found here:
  10. * http://www.bosch-sensortec.com/content/language1/downloads/BST-BMA150-DS000-07.pdf
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25. */
  26. #include <linux/kernel.h>
  27. #include <linux/module.h>
  28. #include <linux/i2c.h>
  29. #include <linux/input.h>
  30. #include <linux/input-polldev.h>
  31. #include <linux/interrupt.h>
  32. #include <linux/delay.h>
  33. #include <linux/slab.h>
  34. #include <linux/pm.h>
  35. #include <linux/pm_runtime.h>
  36. #include <linux/bma150.h>
  37. #define ABSMAX_ACC_VAL 0x01FF
  38. #define ABSMIN_ACC_VAL -(ABSMAX_ACC_VAL)
  39. /* Each axis is represented by a 2-byte data word */
  40. #define BMA150_XYZ_DATA_SIZE 6
  41. /* Input poll interval in milliseconds */
  42. #define BMA150_POLL_INTERVAL 10
  43. #define BMA150_POLL_MAX 200
  44. #define BMA150_POLL_MIN 0
  45. #define BMA150_MODE_NORMAL 0
  46. #define BMA150_MODE_SLEEP 2
  47. #define BMA150_MODE_WAKE_UP 3
  48. /* Data register addresses */
  49. #define BMA150_DATA_0_REG 0x00
  50. #define BMA150_DATA_1_REG 0x01
  51. #define BMA150_DATA_2_REG 0x02
  52. /* Control register addresses */
  53. #define BMA150_CTRL_0_REG 0x0A
  54. #define BMA150_CTRL_1_REG 0x0B
  55. #define BMA150_CTRL_2_REG 0x14
  56. #define BMA150_CTRL_3_REG 0x15
  57. /* Configuration/Setting register addresses */
  58. #define BMA150_CFG_0_REG 0x0C
  59. #define BMA150_CFG_1_REG 0x0D
  60. #define BMA150_CFG_2_REG 0x0E
  61. #define BMA150_CFG_3_REG 0x0F
  62. #define BMA150_CFG_4_REG 0x10
  63. #define BMA150_CFG_5_REG 0x11
  64. #define BMA150_CHIP_ID 2
  65. #define BMA150_CHIP_ID_REG BMA150_DATA_0_REG
  66. #define BMA150_ACC_X_LSB_REG BMA150_DATA_2_REG
  67. #define BMA150_SLEEP_POS 0
  68. #define BMA150_SLEEP_MSK 0x01
  69. #define BMA150_SLEEP_REG BMA150_CTRL_0_REG
  70. #define BMA150_BANDWIDTH_POS 0
  71. #define BMA150_BANDWIDTH_MSK 0x07
  72. #define BMA150_BANDWIDTH_REG BMA150_CTRL_2_REG
  73. #define BMA150_RANGE_POS 3
  74. #define BMA150_RANGE_MSK 0x18
  75. #define BMA150_RANGE_REG BMA150_CTRL_2_REG
  76. #define BMA150_WAKE_UP_POS 0
  77. #define BMA150_WAKE_UP_MSK 0x01
  78. #define BMA150_WAKE_UP_REG BMA150_CTRL_3_REG
  79. #define BMA150_SW_RES_POS 1
  80. #define BMA150_SW_RES_MSK 0x02
  81. #define BMA150_SW_RES_REG BMA150_CTRL_0_REG
  82. /* Any-motion interrupt register fields */
  83. #define BMA150_ANY_MOTION_EN_POS 6
  84. #define BMA150_ANY_MOTION_EN_MSK 0x40
  85. #define BMA150_ANY_MOTION_EN_REG BMA150_CTRL_1_REG
  86. #define BMA150_ANY_MOTION_DUR_POS 6
  87. #define BMA150_ANY_MOTION_DUR_MSK 0xC0
  88. #define BMA150_ANY_MOTION_DUR_REG BMA150_CFG_5_REG
  89. #define BMA150_ANY_MOTION_THRES_REG BMA150_CFG_4_REG
  90. /* Advanced interrupt register fields */
  91. #define BMA150_ADV_INT_EN_POS 6
  92. #define BMA150_ADV_INT_EN_MSK 0x40
  93. #define BMA150_ADV_INT_EN_REG BMA150_CTRL_3_REG
  94. /* High-G interrupt register fields */
  95. #define BMA150_HIGH_G_EN_POS 1
  96. #define BMA150_HIGH_G_EN_MSK 0x02
  97. #define BMA150_HIGH_G_EN_REG BMA150_CTRL_1_REG
  98. #define BMA150_HIGH_G_HYST_POS 3
  99. #define BMA150_HIGH_G_HYST_MSK 0x38
  100. #define BMA150_HIGH_G_HYST_REG BMA150_CFG_5_REG
  101. #define BMA150_HIGH_G_DUR_REG BMA150_CFG_3_REG
  102. #define BMA150_HIGH_G_THRES_REG BMA150_CFG_2_REG
  103. /* Low-G interrupt register fields */
  104. #define BMA150_LOW_G_EN_POS 0
  105. #define BMA150_LOW_G_EN_MSK 0x01
  106. #define BMA150_LOW_G_EN_REG BMA150_CTRL_1_REG
  107. #define BMA150_LOW_G_HYST_POS 0
  108. #define BMA150_LOW_G_HYST_MSK 0x07
  109. #define BMA150_LOW_G_HYST_REG BMA150_CFG_5_REG
  110. #define BMA150_LOW_G_DUR_REG BMA150_CFG_1_REG
  111. #define BMA150_LOW_G_THRES_REG BMA150_CFG_0_REG
  112. struct bma150_data {
  113. struct i2c_client *client;
  114. struct input_polled_dev *input_polled;
  115. struct input_dev *input;
  116. u8 mode;
  117. };
  118. /*
  119. * The settings for the given range, bandwidth and interrupt features
  120. * are stated and verified by Bosch Sensortec where they are configured
  121. * to provide a generic sensitivity performance.
  122. */
  123. static const struct bma150_cfg default_cfg = {
  124. .any_motion_int = 1,
  125. .hg_int = 1,
  126. .lg_int = 1,
  127. .any_motion_dur = 0,
  128. .any_motion_thres = 0,
  129. .hg_hyst = 0,
  130. .hg_dur = 150,
  131. .hg_thres = 160,
  132. .lg_hyst = 0,
  133. .lg_dur = 150,
  134. .lg_thres = 20,
  135. .range = BMA150_RANGE_2G,
  136. .bandwidth = BMA150_BW_50HZ
  137. };
  138. static int bma150_write_byte(struct i2c_client *client, u8 reg, u8 val)
  139. {
  140. s32 ret;
  141. /* As per specification, disable irq in between register writes */
  142. if (client->irq)
  143. disable_irq_nosync(client->irq);
  144. ret = i2c_smbus_write_byte_data(client, reg, val);
  145. if (client->irq)
  146. enable_irq(client->irq);
  147. return ret;
  148. }
  149. static int bma150_set_reg_bits(struct i2c_client *client,
  150. int val, int shift, u8 mask, u8 reg)
  151. {
  152. int data;
  153. data = i2c_smbus_read_byte_data(client, reg);
  154. if (data < 0)
  155. return data;
  156. data = (data & ~mask) | ((val << shift) & mask);
  157. return bma150_write_byte(client, reg, data);
  158. }
  159. static int bma150_set_mode(struct bma150_data *bma150, u8 mode)
  160. {
  161. int error;
  162. error = bma150_set_reg_bits(bma150->client, mode, BMA150_WAKE_UP_POS,
  163. BMA150_WAKE_UP_MSK, BMA150_WAKE_UP_REG);
  164. if (error)
  165. return error;
  166. error = bma150_set_reg_bits(bma150->client, mode, BMA150_SLEEP_POS,
  167. BMA150_SLEEP_MSK, BMA150_SLEEP_REG);
  168. if (error)
  169. return error;
  170. if (mode == BMA150_MODE_NORMAL)
  171. usleep_range(2000, 2100);
  172. bma150->mode = mode;
  173. return 0;
  174. }
  175. static int bma150_soft_reset(struct bma150_data *bma150)
  176. {
  177. int error;
  178. error = bma150_set_reg_bits(bma150->client, 1, BMA150_SW_RES_POS,
  179. BMA150_SW_RES_MSK, BMA150_SW_RES_REG);
  180. if (error)
  181. return error;
  182. usleep_range(2000, 2100);
  183. return 0;
  184. }
  185. static int bma150_set_range(struct bma150_data *bma150, u8 range)
  186. {
  187. return bma150_set_reg_bits(bma150->client, range, BMA150_RANGE_POS,
  188. BMA150_RANGE_MSK, BMA150_RANGE_REG);
  189. }
  190. static int bma150_set_bandwidth(struct bma150_data *bma150, u8 bw)
  191. {
  192. return bma150_set_reg_bits(bma150->client, bw, BMA150_BANDWIDTH_POS,
  193. BMA150_BANDWIDTH_MSK, BMA150_BANDWIDTH_REG);
  194. }
  195. static int bma150_set_low_g_interrupt(struct bma150_data *bma150,
  196. u8 enable, u8 hyst, u8 dur, u8 thres)
  197. {
  198. int error;
  199. error = bma150_set_reg_bits(bma150->client, hyst,
  200. BMA150_LOW_G_HYST_POS, BMA150_LOW_G_HYST_MSK,
  201. BMA150_LOW_G_HYST_REG);
  202. if (error)
  203. return error;
  204. error = bma150_write_byte(bma150->client, BMA150_LOW_G_DUR_REG, dur);
  205. if (error)
  206. return error;
  207. error = bma150_write_byte(bma150->client, BMA150_LOW_G_THRES_REG, thres);
  208. if (error)
  209. return error;
  210. return bma150_set_reg_bits(bma150->client, !!enable,
  211. BMA150_LOW_G_EN_POS, BMA150_LOW_G_EN_MSK,
  212. BMA150_LOW_G_EN_REG);
  213. }
  214. static int bma150_set_high_g_interrupt(struct bma150_data *bma150,
  215. u8 enable, u8 hyst, u8 dur, u8 thres)
  216. {
  217. int error;
  218. error = bma150_set_reg_bits(bma150->client, hyst,
  219. BMA150_HIGH_G_HYST_POS, BMA150_HIGH_G_HYST_MSK,
  220. BMA150_HIGH_G_HYST_REG);
  221. if (error)
  222. return error;
  223. error = bma150_write_byte(bma150->client,
  224. BMA150_HIGH_G_DUR_REG, dur);
  225. if (error)
  226. return error;
  227. error = bma150_write_byte(bma150->client,
  228. BMA150_HIGH_G_THRES_REG, thres);
  229. if (error)
  230. return error;
  231. return bma150_set_reg_bits(bma150->client, !!enable,
  232. BMA150_HIGH_G_EN_POS, BMA150_HIGH_G_EN_MSK,
  233. BMA150_HIGH_G_EN_REG);
  234. }
  235. static int bma150_set_any_motion_interrupt(struct bma150_data *bma150,
  236. u8 enable, u8 dur, u8 thres)
  237. {
  238. int error;
  239. error = bma150_set_reg_bits(bma150->client, dur,
  240. BMA150_ANY_MOTION_DUR_POS,
  241. BMA150_ANY_MOTION_DUR_MSK,
  242. BMA150_ANY_MOTION_DUR_REG);
  243. if (error)
  244. return error;
  245. error = bma150_write_byte(bma150->client,
  246. BMA150_ANY_MOTION_THRES_REG, thres);
  247. if (error)
  248. return error;
  249. error = bma150_set_reg_bits(bma150->client, !!enable,
  250. BMA150_ADV_INT_EN_POS, BMA150_ADV_INT_EN_MSK,
  251. BMA150_ADV_INT_EN_REG);
  252. if (error)
  253. return error;
  254. return bma150_set_reg_bits(bma150->client, !!enable,
  255. BMA150_ANY_MOTION_EN_POS,
  256. BMA150_ANY_MOTION_EN_MSK,
  257. BMA150_ANY_MOTION_EN_REG);
  258. }
  259. static void bma150_report_xyz(struct bma150_data *bma150)
  260. {
  261. u8 data[BMA150_XYZ_DATA_SIZE];
  262. s16 x, y, z;
  263. s32 ret;
  264. ret = i2c_smbus_read_i2c_block_data(bma150->client,
  265. BMA150_ACC_X_LSB_REG, BMA150_XYZ_DATA_SIZE, data);
  266. if (ret != BMA150_XYZ_DATA_SIZE)
  267. return;
  268. x = ((0xc0 & data[0]) >> 6) | (data[1] << 2);
  269. y = ((0xc0 & data[2]) >> 6) | (data[3] << 2);
  270. z = ((0xc0 & data[4]) >> 6) | (data[5] << 2);
  271. x = sign_extend32(x, 9);
  272. y = sign_extend32(y, 9);
  273. z = sign_extend32(z, 9);
  274. input_report_abs(bma150->input, ABS_X, x);
  275. input_report_abs(bma150->input, ABS_Y, y);
  276. input_report_abs(bma150->input, ABS_Z, z);
  277. input_sync(bma150->input);
  278. }
  279. static irqreturn_t bma150_irq_thread(int irq, void *dev)
  280. {
  281. bma150_report_xyz(dev);
  282. return IRQ_HANDLED;
  283. }
  284. static void bma150_poll(struct input_polled_dev *dev)
  285. {
  286. bma150_report_xyz(dev->private);
  287. }
  288. static int bma150_open(struct bma150_data *bma150)
  289. {
  290. int error;
  291. error = pm_runtime_get_sync(&bma150->client->dev);
  292. if (error < 0 && error != -ENOSYS)
  293. return error;
  294. /*
  295. * See if runtime PM woke up the device. If runtime PM
  296. * is disabled we need to do it ourselves.
  297. */
  298. if (bma150->mode != BMA150_MODE_NORMAL) {
  299. error = bma150_set_mode(bma150, BMA150_MODE_NORMAL);
  300. if (error)
  301. return error;
  302. }
  303. return 0;
  304. }
  305. static void bma150_close(struct bma150_data *bma150)
  306. {
  307. pm_runtime_put_sync(&bma150->client->dev);
  308. if (bma150->mode != BMA150_MODE_SLEEP)
  309. bma150_set_mode(bma150, BMA150_MODE_SLEEP);
  310. }
  311. static int bma150_irq_open(struct input_dev *input)
  312. {
  313. struct bma150_data *bma150 = input_get_drvdata(input);
  314. return bma150_open(bma150);
  315. }
  316. static void bma150_irq_close(struct input_dev *input)
  317. {
  318. struct bma150_data *bma150 = input_get_drvdata(input);
  319. bma150_close(bma150);
  320. }
  321. static void bma150_poll_open(struct input_polled_dev *ipoll_dev)
  322. {
  323. struct bma150_data *bma150 = ipoll_dev->private;
  324. bma150_open(bma150);
  325. }
  326. static void bma150_poll_close(struct input_polled_dev *ipoll_dev)
  327. {
  328. struct bma150_data *bma150 = ipoll_dev->private;
  329. bma150_close(bma150);
  330. }
  331. static int bma150_initialize(struct bma150_data *bma150,
  332. const struct bma150_cfg *cfg)
  333. {
  334. int error;
  335. error = bma150_soft_reset(bma150);
  336. if (error)
  337. return error;
  338. error = bma150_set_bandwidth(bma150, cfg->bandwidth);
  339. if (error)
  340. return error;
  341. error = bma150_set_range(bma150, cfg->range);
  342. if (error)
  343. return error;
  344. if (bma150->client->irq) {
  345. error = bma150_set_any_motion_interrupt(bma150,
  346. cfg->any_motion_int,
  347. cfg->any_motion_dur,
  348. cfg->any_motion_thres);
  349. if (error)
  350. return error;
  351. error = bma150_set_high_g_interrupt(bma150,
  352. cfg->hg_int, cfg->hg_hyst,
  353. cfg->hg_dur, cfg->hg_thres);
  354. if (error)
  355. return error;
  356. error = bma150_set_low_g_interrupt(bma150,
  357. cfg->lg_int, cfg->lg_hyst,
  358. cfg->lg_dur, cfg->lg_thres);
  359. if (error)
  360. return error;
  361. }
  362. return bma150_set_mode(bma150, BMA150_MODE_SLEEP);
  363. }
  364. static void bma150_init_input_device(struct bma150_data *bma150,
  365. struct input_dev *idev)
  366. {
  367. idev->name = BMA150_DRIVER;
  368. idev->phys = BMA150_DRIVER "/input0";
  369. idev->id.bustype = BUS_I2C;
  370. idev->dev.parent = &bma150->client->dev;
  371. idev->evbit[0] = BIT_MASK(EV_ABS);
  372. input_set_abs_params(idev, ABS_X, ABSMIN_ACC_VAL, ABSMAX_ACC_VAL, 0, 0);
  373. input_set_abs_params(idev, ABS_Y, ABSMIN_ACC_VAL, ABSMAX_ACC_VAL, 0, 0);
  374. input_set_abs_params(idev, ABS_Z, ABSMIN_ACC_VAL, ABSMAX_ACC_VAL, 0, 0);
  375. }
  376. static int bma150_register_input_device(struct bma150_data *bma150)
  377. {
  378. struct input_dev *idev;
  379. int error;
  380. idev = input_allocate_device();
  381. if (!idev)
  382. return -ENOMEM;
  383. bma150_init_input_device(bma150, idev);
  384. idev->open = bma150_irq_open;
  385. idev->close = bma150_irq_close;
  386. input_set_drvdata(idev, bma150);
  387. bma150->input = idev;
  388. error = input_register_device(idev);
  389. if (error) {
  390. input_free_device(idev);
  391. return error;
  392. }
  393. return 0;
  394. }
  395. static int bma150_register_polled_device(struct bma150_data *bma150)
  396. {
  397. struct input_polled_dev *ipoll_dev;
  398. int error;
  399. ipoll_dev = input_allocate_polled_device();
  400. if (!ipoll_dev)
  401. return -ENOMEM;
  402. ipoll_dev->private = bma150;
  403. ipoll_dev->open = bma150_poll_open;
  404. ipoll_dev->close = bma150_poll_close;
  405. ipoll_dev->poll = bma150_poll;
  406. ipoll_dev->poll_interval = BMA150_POLL_INTERVAL;
  407. ipoll_dev->poll_interval_min = BMA150_POLL_MIN;
  408. ipoll_dev->poll_interval_max = BMA150_POLL_MAX;
  409. bma150_init_input_device(bma150, ipoll_dev->input);
  410. bma150->input_polled = ipoll_dev;
  411. bma150->input = ipoll_dev->input;
  412. error = input_register_polled_device(ipoll_dev);
  413. if (error) {
  414. input_free_polled_device(ipoll_dev);
  415. return error;
  416. }
  417. return 0;
  418. }
  419. static int bma150_probe(struct i2c_client *client,
  420. const struct i2c_device_id *id)
  421. {
  422. const struct bma150_platform_data *pdata =
  423. dev_get_platdata(&client->dev);
  424. const struct bma150_cfg *cfg;
  425. struct bma150_data *bma150;
  426. int chip_id;
  427. int error;
  428. if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
  429. dev_err(&client->dev, "i2c_check_functionality error\n");
  430. return -EIO;
  431. }
  432. chip_id = i2c_smbus_read_byte_data(client, BMA150_CHIP_ID_REG);
  433. if (chip_id != BMA150_CHIP_ID) {
  434. dev_err(&client->dev, "BMA150 chip id error: %d\n", chip_id);
  435. return -EINVAL;
  436. }
  437. bma150 = kzalloc(sizeof(struct bma150_data), GFP_KERNEL);
  438. if (!bma150)
  439. return -ENOMEM;
  440. bma150->client = client;
  441. if (pdata) {
  442. if (pdata->irq_gpio_cfg) {
  443. error = pdata->irq_gpio_cfg();
  444. if (error) {
  445. dev_err(&client->dev,
  446. "IRQ GPIO conf. error %d, error %d\n",
  447. client->irq, error);
  448. goto err_free_mem;
  449. }
  450. }
  451. cfg = &pdata->cfg;
  452. } else {
  453. cfg = &default_cfg;
  454. }
  455. error = bma150_initialize(bma150, cfg);
  456. if (error)
  457. goto err_free_mem;
  458. if (client->irq > 0) {
  459. error = bma150_register_input_device(bma150);
  460. if (error)
  461. goto err_free_mem;
  462. error = request_threaded_irq(client->irq,
  463. NULL, bma150_irq_thread,
  464. IRQF_TRIGGER_RISING | IRQF_ONESHOT,
  465. BMA150_DRIVER, bma150);
  466. if (error) {
  467. dev_err(&client->dev,
  468. "irq request failed %d, error %d\n",
  469. client->irq, error);
  470. input_unregister_device(bma150->input);
  471. goto err_free_mem;
  472. }
  473. } else {
  474. error = bma150_register_polled_device(bma150);
  475. if (error)
  476. goto err_free_mem;
  477. }
  478. i2c_set_clientdata(client, bma150);
  479. pm_runtime_enable(&client->dev);
  480. return 0;
  481. err_free_mem:
  482. kfree(bma150);
  483. return error;
  484. }
  485. static int bma150_remove(struct i2c_client *client)
  486. {
  487. struct bma150_data *bma150 = i2c_get_clientdata(client);
  488. pm_runtime_disable(&client->dev);
  489. if (client->irq > 0) {
  490. free_irq(client->irq, bma150);
  491. input_unregister_device(bma150->input);
  492. } else {
  493. input_unregister_polled_device(bma150->input_polled);
  494. input_free_polled_device(bma150->input_polled);
  495. }
  496. kfree(bma150);
  497. return 0;
  498. }
  499. #ifdef CONFIG_PM
  500. static int bma150_suspend(struct device *dev)
  501. {
  502. struct i2c_client *client = to_i2c_client(dev);
  503. struct bma150_data *bma150 = i2c_get_clientdata(client);
  504. return bma150_set_mode(bma150, BMA150_MODE_SLEEP);
  505. }
  506. static int bma150_resume(struct device *dev)
  507. {
  508. struct i2c_client *client = to_i2c_client(dev);
  509. struct bma150_data *bma150 = i2c_get_clientdata(client);
  510. return bma150_set_mode(bma150, BMA150_MODE_NORMAL);
  511. }
  512. #endif
  513. static UNIVERSAL_DEV_PM_OPS(bma150_pm, bma150_suspend, bma150_resume, NULL);
  514. static const struct i2c_device_id bma150_id[] = {
  515. { "bma150", 0 },
  516. { "smb380", 0 },
  517. { "bma023", 0 },
  518. { }
  519. };
  520. MODULE_DEVICE_TABLE(i2c, bma150_id);
  521. static struct i2c_driver bma150_driver = {
  522. .driver = {
  523. .name = BMA150_DRIVER,
  524. .pm = &bma150_pm,
  525. },
  526. .class = I2C_CLASS_HWMON,
  527. .id_table = bma150_id,
  528. .probe = bma150_probe,
  529. .remove = bma150_remove,
  530. };
  531. module_i2c_driver(bma150_driver);
  532. MODULE_AUTHOR("Albert Zhang <xu.zhang@bosch-sensortec.com>");
  533. MODULE_DESCRIPTION("BMA150 driver");
  534. MODULE_LICENSE("GPL");