bma150.c 16 KB

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