ak8975.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /*
  2. * A sensor driver for the magnetometer AK8975.
  3. *
  4. * Magnetic compass sensor driver for monitoring magnetic flux information.
  5. *
  6. * Copyright (c) 2010, NVIDIA Corporation.
  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, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21. */
  22. #include <linux/module.h>
  23. #include <linux/kernel.h>
  24. #include <linux/slab.h>
  25. #include <linux/i2c.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/err.h>
  28. #include <linux/mutex.h>
  29. #include <linux/delay.h>
  30. #include <linux/bitops.h>
  31. #include <linux/gpio.h>
  32. #include <linux/of_gpio.h>
  33. #include <linux/acpi.h>
  34. #include <linux/iio/iio.h>
  35. #include <linux/iio/sysfs.h>
  36. /*
  37. * Register definitions, as well as various shifts and masks to get at the
  38. * individual fields of the registers.
  39. */
  40. #define AK8975_REG_WIA 0x00
  41. #define AK8975_DEVICE_ID 0x48
  42. #define AK8975_REG_INFO 0x01
  43. #define AK8975_REG_ST1 0x02
  44. #define AK8975_REG_ST1_DRDY_SHIFT 0
  45. #define AK8975_REG_ST1_DRDY_MASK (1 << AK8975_REG_ST1_DRDY_SHIFT)
  46. #define AK8975_REG_HXL 0x03
  47. #define AK8975_REG_HXH 0x04
  48. #define AK8975_REG_HYL 0x05
  49. #define AK8975_REG_HYH 0x06
  50. #define AK8975_REG_HZL 0x07
  51. #define AK8975_REG_HZH 0x08
  52. #define AK8975_REG_ST2 0x09
  53. #define AK8975_REG_ST2_DERR_SHIFT 2
  54. #define AK8975_REG_ST2_DERR_MASK (1 << AK8975_REG_ST2_DERR_SHIFT)
  55. #define AK8975_REG_ST2_HOFL_SHIFT 3
  56. #define AK8975_REG_ST2_HOFL_MASK (1 << AK8975_REG_ST2_HOFL_SHIFT)
  57. #define AK8975_REG_CNTL 0x0A
  58. #define AK8975_REG_CNTL_MODE_SHIFT 0
  59. #define AK8975_REG_CNTL_MODE_MASK (0xF << AK8975_REG_CNTL_MODE_SHIFT)
  60. #define AK8975_REG_CNTL_MODE_POWER_DOWN 0
  61. #define AK8975_REG_CNTL_MODE_ONCE 1
  62. #define AK8975_REG_CNTL_MODE_SELF_TEST 8
  63. #define AK8975_REG_CNTL_MODE_FUSE_ROM 0xF
  64. #define AK8975_REG_RSVC 0x0B
  65. #define AK8975_REG_ASTC 0x0C
  66. #define AK8975_REG_TS1 0x0D
  67. #define AK8975_REG_TS2 0x0E
  68. #define AK8975_REG_I2CDIS 0x0F
  69. #define AK8975_REG_ASAX 0x10
  70. #define AK8975_REG_ASAY 0x11
  71. #define AK8975_REG_ASAZ 0x12
  72. #define AK8975_MAX_REGS AK8975_REG_ASAZ
  73. /*
  74. * Miscellaneous values.
  75. */
  76. #define AK8975_MAX_CONVERSION_TIMEOUT 500
  77. #define AK8975_CONVERSION_DONE_POLL_TIME 10
  78. #define AK8975_DATA_READY_TIMEOUT ((100*HZ)/1000)
  79. #define RAW_TO_GAUSS_8975(asa) ((((asa) + 128) * 3000) / 256)
  80. #define RAW_TO_GAUSS_8963(asa) ((((asa) + 128) * 6000) / 256)
  81. /* Compatible Asahi Kasei Compass parts */
  82. enum asahi_compass_chipset {
  83. AK8975,
  84. AK8963,
  85. };
  86. /*
  87. * Per-instance context data for the device.
  88. */
  89. struct ak8975_data {
  90. struct i2c_client *client;
  91. struct attribute_group attrs;
  92. struct mutex lock;
  93. u8 asa[3];
  94. long raw_to_gauss[3];
  95. u8 reg_cache[AK8975_MAX_REGS];
  96. int eoc_gpio;
  97. int eoc_irq;
  98. wait_queue_head_t data_ready_queue;
  99. unsigned long flags;
  100. enum asahi_compass_chipset chipset;
  101. };
  102. static const int ak8975_index_to_reg[] = {
  103. AK8975_REG_HXL, AK8975_REG_HYL, AK8975_REG_HZL,
  104. };
  105. /*
  106. * Helper function to write to the I2C device's registers.
  107. */
  108. static int ak8975_write_data(struct i2c_client *client,
  109. u8 reg, u8 val, u8 mask, u8 shift)
  110. {
  111. struct iio_dev *indio_dev = i2c_get_clientdata(client);
  112. struct ak8975_data *data = iio_priv(indio_dev);
  113. u8 regval;
  114. int ret;
  115. regval = (data->reg_cache[reg] & ~mask) | (val << shift);
  116. ret = i2c_smbus_write_byte_data(client, reg, regval);
  117. if (ret < 0) {
  118. dev_err(&client->dev, "Write to device fails status %x\n", ret);
  119. return ret;
  120. }
  121. data->reg_cache[reg] = regval;
  122. return 0;
  123. }
  124. /*
  125. * Handle data ready irq
  126. */
  127. static irqreturn_t ak8975_irq_handler(int irq, void *data)
  128. {
  129. struct ak8975_data *ak8975 = data;
  130. set_bit(0, &ak8975->flags);
  131. wake_up(&ak8975->data_ready_queue);
  132. return IRQ_HANDLED;
  133. }
  134. /*
  135. * Install data ready interrupt handler
  136. */
  137. static int ak8975_setup_irq(struct ak8975_data *data)
  138. {
  139. struct i2c_client *client = data->client;
  140. int rc;
  141. int irq;
  142. if (client->irq)
  143. irq = client->irq;
  144. else
  145. irq = gpio_to_irq(data->eoc_gpio);
  146. rc = request_irq(irq, ak8975_irq_handler,
  147. IRQF_TRIGGER_RISING | IRQF_ONESHOT,
  148. dev_name(&client->dev), data);
  149. if (rc < 0) {
  150. dev_err(&client->dev,
  151. "irq %d request failed, (gpio %d): %d\n",
  152. irq, data->eoc_gpio, rc);
  153. return rc;
  154. }
  155. init_waitqueue_head(&data->data_ready_queue);
  156. clear_bit(0, &data->flags);
  157. data->eoc_irq = irq;
  158. return rc;
  159. }
  160. /*
  161. * Perform some start-of-day setup, including reading the asa calibration
  162. * values and caching them.
  163. */
  164. static int ak8975_setup(struct i2c_client *client)
  165. {
  166. struct iio_dev *indio_dev = i2c_get_clientdata(client);
  167. struct ak8975_data *data = iio_priv(indio_dev);
  168. u8 device_id;
  169. int ret;
  170. /* Confirm that the device we're talking to is really an AK8975. */
  171. ret = i2c_smbus_read_byte_data(client, AK8975_REG_WIA);
  172. if (ret < 0) {
  173. dev_err(&client->dev, "Error reading WIA\n");
  174. return ret;
  175. }
  176. device_id = ret;
  177. if (device_id != AK8975_DEVICE_ID) {
  178. dev_err(&client->dev, "Device ak8975 not found\n");
  179. return -ENODEV;
  180. }
  181. /* Write the fused rom access mode. */
  182. ret = ak8975_write_data(client,
  183. AK8975_REG_CNTL,
  184. AK8975_REG_CNTL_MODE_FUSE_ROM,
  185. AK8975_REG_CNTL_MODE_MASK,
  186. AK8975_REG_CNTL_MODE_SHIFT);
  187. if (ret < 0) {
  188. dev_err(&client->dev, "Error in setting fuse access mode\n");
  189. return ret;
  190. }
  191. /* Get asa data and store in the device data. */
  192. ret = i2c_smbus_read_i2c_block_data(client, AK8975_REG_ASAX,
  193. 3, data->asa);
  194. if (ret < 0) {
  195. dev_err(&client->dev, "Not able to read asa data\n");
  196. return ret;
  197. }
  198. /* After reading fuse ROM data set power-down mode */
  199. ret = ak8975_write_data(client,
  200. AK8975_REG_CNTL,
  201. AK8975_REG_CNTL_MODE_POWER_DOWN,
  202. AK8975_REG_CNTL_MODE_MASK,
  203. AK8975_REG_CNTL_MODE_SHIFT);
  204. if (data->eoc_gpio > 0 || client->irq) {
  205. ret = ak8975_setup_irq(data);
  206. if (ret < 0) {
  207. dev_err(&client->dev,
  208. "Error setting data ready interrupt\n");
  209. return ret;
  210. }
  211. }
  212. if (ret < 0) {
  213. dev_err(&client->dev, "Error in setting power-down mode\n");
  214. return ret;
  215. }
  216. /*
  217. * Precalculate scale factor (in Gauss units) for each axis and
  218. * store in the device data.
  219. *
  220. * This scale factor is axis-dependent, and is derived from 3 calibration
  221. * factors ASA(x), ASA(y), and ASA(z).
  222. *
  223. * These ASA values are read from the sensor device at start of day, and
  224. * cached in the device context struct.
  225. *
  226. * Adjusting the flux value with the sensitivity adjustment value should be
  227. * done via the following formula:
  228. *
  229. * Hadj = H * ( ( ( (ASA-128)*0.5 ) / 128 ) + 1 )
  230. *
  231. * where H is the raw value, ASA is the sensitivity adjustment, and Hadj
  232. * is the resultant adjusted value.
  233. *
  234. * We reduce the formula to:
  235. *
  236. * Hadj = H * (ASA + 128) / 256
  237. *
  238. * H is in the range of -4096 to 4095. The magnetometer has a range of
  239. * +-1229uT. To go from the raw value to uT is:
  240. *
  241. * HuT = H * 1229/4096, or roughly, 3/10.
  242. *
  243. * Since 1uT = 0.01 gauss, our final scale factor becomes:
  244. *
  245. * Hadj = H * ((ASA + 128) / 256) * 3/10 * 1/100
  246. * Hadj = H * ((ASA + 128) * 0.003) / 256
  247. *
  248. * Since ASA doesn't change, we cache the resultant scale factor into the
  249. * device context in ak8975_setup().
  250. */
  251. if (data->chipset == AK8963) {
  252. /*
  253. * H range is +-8190 and magnetometer range is +-4912.
  254. * So HuT using the above explanation for 8975,
  255. * 4912/8190 = ~ 6/10.
  256. * So the Hadj should use 6/10 instead of 3/10.
  257. */
  258. data->raw_to_gauss[0] = RAW_TO_GAUSS_8963(data->asa[0]);
  259. data->raw_to_gauss[1] = RAW_TO_GAUSS_8963(data->asa[1]);
  260. data->raw_to_gauss[2] = RAW_TO_GAUSS_8963(data->asa[2]);
  261. } else {
  262. data->raw_to_gauss[0] = RAW_TO_GAUSS_8975(data->asa[0]);
  263. data->raw_to_gauss[1] = RAW_TO_GAUSS_8975(data->asa[1]);
  264. data->raw_to_gauss[2] = RAW_TO_GAUSS_8975(data->asa[2]);
  265. }
  266. return 0;
  267. }
  268. static int wait_conversion_complete_gpio(struct ak8975_data *data)
  269. {
  270. struct i2c_client *client = data->client;
  271. u32 timeout_ms = AK8975_MAX_CONVERSION_TIMEOUT;
  272. int ret;
  273. /* Wait for the conversion to complete. */
  274. while (timeout_ms) {
  275. msleep(AK8975_CONVERSION_DONE_POLL_TIME);
  276. if (gpio_get_value(data->eoc_gpio))
  277. break;
  278. timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
  279. }
  280. if (!timeout_ms) {
  281. dev_err(&client->dev, "Conversion timeout happened\n");
  282. return -EINVAL;
  283. }
  284. ret = i2c_smbus_read_byte_data(client, AK8975_REG_ST1);
  285. if (ret < 0)
  286. dev_err(&client->dev, "Error in reading ST1\n");
  287. return ret;
  288. }
  289. static int wait_conversion_complete_polled(struct ak8975_data *data)
  290. {
  291. struct i2c_client *client = data->client;
  292. u8 read_status;
  293. u32 timeout_ms = AK8975_MAX_CONVERSION_TIMEOUT;
  294. int ret;
  295. /* Wait for the conversion to complete. */
  296. while (timeout_ms) {
  297. msleep(AK8975_CONVERSION_DONE_POLL_TIME);
  298. ret = i2c_smbus_read_byte_data(client, AK8975_REG_ST1);
  299. if (ret < 0) {
  300. dev_err(&client->dev, "Error in reading ST1\n");
  301. return ret;
  302. }
  303. read_status = ret;
  304. if (read_status)
  305. break;
  306. timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
  307. }
  308. if (!timeout_ms) {
  309. dev_err(&client->dev, "Conversion timeout happened\n");
  310. return -EINVAL;
  311. }
  312. return read_status;
  313. }
  314. /* Returns 0 if the end of conversion interrupt occured or -ETIME otherwise */
  315. static int wait_conversion_complete_interrupt(struct ak8975_data *data)
  316. {
  317. int ret;
  318. ret = wait_event_timeout(data->data_ready_queue,
  319. test_bit(0, &data->flags),
  320. AK8975_DATA_READY_TIMEOUT);
  321. clear_bit(0, &data->flags);
  322. return ret > 0 ? 0 : -ETIME;
  323. }
  324. /*
  325. * Emits the raw flux value for the x, y, or z axis.
  326. */
  327. static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
  328. {
  329. struct ak8975_data *data = iio_priv(indio_dev);
  330. struct i2c_client *client = data->client;
  331. int ret;
  332. mutex_lock(&data->lock);
  333. /* Set up the device for taking a sample. */
  334. ret = ak8975_write_data(client,
  335. AK8975_REG_CNTL,
  336. AK8975_REG_CNTL_MODE_ONCE,
  337. AK8975_REG_CNTL_MODE_MASK,
  338. AK8975_REG_CNTL_MODE_SHIFT);
  339. if (ret < 0) {
  340. dev_err(&client->dev, "Error in setting operating mode\n");
  341. goto exit;
  342. }
  343. /* Wait for the conversion to complete. */
  344. if (data->eoc_irq)
  345. ret = wait_conversion_complete_interrupt(data);
  346. else if (gpio_is_valid(data->eoc_gpio))
  347. ret = wait_conversion_complete_gpio(data);
  348. else
  349. ret = wait_conversion_complete_polled(data);
  350. if (ret < 0)
  351. goto exit;
  352. /* This will be executed only for non-interrupt based waiting case */
  353. if (ret & AK8975_REG_ST1_DRDY_MASK) {
  354. ret = i2c_smbus_read_byte_data(client, AK8975_REG_ST2);
  355. if (ret < 0) {
  356. dev_err(&client->dev, "Error in reading ST2\n");
  357. goto exit;
  358. }
  359. if (ret & (AK8975_REG_ST2_DERR_MASK |
  360. AK8975_REG_ST2_HOFL_MASK)) {
  361. dev_err(&client->dev, "ST2 status error 0x%x\n", ret);
  362. ret = -EINVAL;
  363. goto exit;
  364. }
  365. }
  366. /* Read the flux value from the appropriate register
  367. (the register is specified in the iio device attributes). */
  368. ret = i2c_smbus_read_word_data(client, ak8975_index_to_reg[index]);
  369. if (ret < 0) {
  370. dev_err(&client->dev, "Read axis data fails\n");
  371. goto exit;
  372. }
  373. mutex_unlock(&data->lock);
  374. /* Clamp to valid range. */
  375. *val = clamp_t(s16, ret, -4096, 4095);
  376. return IIO_VAL_INT;
  377. exit:
  378. mutex_unlock(&data->lock);
  379. return ret;
  380. }
  381. static int ak8975_read_raw(struct iio_dev *indio_dev,
  382. struct iio_chan_spec const *chan,
  383. int *val, int *val2,
  384. long mask)
  385. {
  386. struct ak8975_data *data = iio_priv(indio_dev);
  387. switch (mask) {
  388. case IIO_CHAN_INFO_RAW:
  389. return ak8975_read_axis(indio_dev, chan->address, val);
  390. case IIO_CHAN_INFO_SCALE:
  391. *val = 0;
  392. *val2 = data->raw_to_gauss[chan->address];
  393. return IIO_VAL_INT_PLUS_MICRO;
  394. }
  395. return -EINVAL;
  396. }
  397. #define AK8975_CHANNEL(axis, index) \
  398. { \
  399. .type = IIO_MAGN, \
  400. .modified = 1, \
  401. .channel2 = IIO_MOD_##axis, \
  402. .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
  403. BIT(IIO_CHAN_INFO_SCALE), \
  404. .address = index, \
  405. }
  406. static const struct iio_chan_spec ak8975_channels[] = {
  407. AK8975_CHANNEL(X, 0), AK8975_CHANNEL(Y, 1), AK8975_CHANNEL(Z, 2),
  408. };
  409. static const struct iio_info ak8975_info = {
  410. .read_raw = &ak8975_read_raw,
  411. .driver_module = THIS_MODULE,
  412. };
  413. static const struct acpi_device_id ak_acpi_match[] = {
  414. {"AK8975", AK8975},
  415. {"AK8963", AK8963},
  416. {"INVN6500", AK8963},
  417. { },
  418. };
  419. MODULE_DEVICE_TABLE(acpi, ak_acpi_match);
  420. static char *ak8975_match_acpi_device(struct device *dev,
  421. enum asahi_compass_chipset *chipset)
  422. {
  423. const struct acpi_device_id *id;
  424. id = acpi_match_device(dev->driver->acpi_match_table, dev);
  425. if (!id)
  426. return NULL;
  427. *chipset = (int)id->driver_data;
  428. return (char *)dev_name(dev);
  429. }
  430. static int ak8975_probe(struct i2c_client *client,
  431. const struct i2c_device_id *id)
  432. {
  433. struct ak8975_data *data;
  434. struct iio_dev *indio_dev;
  435. int eoc_gpio;
  436. int err;
  437. char *name = NULL;
  438. /* Grab and set up the supplied GPIO. */
  439. if (client->dev.platform_data)
  440. eoc_gpio = *(int *)(client->dev.platform_data);
  441. else if (client->dev.of_node)
  442. eoc_gpio = of_get_gpio(client->dev.of_node, 0);
  443. else
  444. eoc_gpio = -1;
  445. if (eoc_gpio == -EPROBE_DEFER)
  446. return -EPROBE_DEFER;
  447. /* We may not have a GPIO based IRQ to scan, that is fine, we will
  448. poll if so */
  449. if (gpio_is_valid(eoc_gpio)) {
  450. err = gpio_request_one(eoc_gpio, GPIOF_IN, "ak_8975");
  451. if (err < 0) {
  452. dev_err(&client->dev,
  453. "failed to request GPIO %d, error %d\n",
  454. eoc_gpio, err);
  455. goto exit;
  456. }
  457. }
  458. /* Register with IIO */
  459. indio_dev = iio_device_alloc(sizeof(*data));
  460. if (indio_dev == NULL) {
  461. err = -ENOMEM;
  462. goto exit_gpio;
  463. }
  464. data = iio_priv(indio_dev);
  465. i2c_set_clientdata(client, indio_dev);
  466. data->client = client;
  467. data->eoc_gpio = eoc_gpio;
  468. data->eoc_irq = 0;
  469. /* id will be NULL when enumerated via ACPI */
  470. if (id) {
  471. data->chipset =
  472. (enum asahi_compass_chipset)(id->driver_data);
  473. name = (char *) id->name;
  474. } else if (ACPI_HANDLE(&client->dev))
  475. name = ak8975_match_acpi_device(&client->dev, &data->chipset);
  476. else {
  477. err = -ENOSYS;
  478. goto exit_free_iio;
  479. }
  480. dev_dbg(&client->dev, "Asahi compass chip %s\n", name);
  481. /* Perform some basic start-of-day setup of the device. */
  482. err = ak8975_setup(client);
  483. if (err < 0) {
  484. dev_err(&client->dev, "AK8975 initialization fails\n");
  485. goto exit_free_iio;
  486. }
  487. data->client = client;
  488. mutex_init(&data->lock);
  489. data->eoc_gpio = eoc_gpio;
  490. indio_dev->dev.parent = &client->dev;
  491. indio_dev->channels = ak8975_channels;
  492. indio_dev->num_channels = ARRAY_SIZE(ak8975_channels);
  493. indio_dev->info = &ak8975_info;
  494. indio_dev->modes = INDIO_DIRECT_MODE;
  495. indio_dev->name = name;
  496. err = iio_device_register(indio_dev);
  497. if (err < 0)
  498. goto exit_free_iio;
  499. return 0;
  500. exit_free_iio:
  501. iio_device_free(indio_dev);
  502. if (data->eoc_irq)
  503. free_irq(data->eoc_irq, data);
  504. exit_gpio:
  505. if (gpio_is_valid(eoc_gpio))
  506. gpio_free(eoc_gpio);
  507. exit:
  508. return err;
  509. }
  510. static int ak8975_remove(struct i2c_client *client)
  511. {
  512. struct iio_dev *indio_dev = i2c_get_clientdata(client);
  513. struct ak8975_data *data = iio_priv(indio_dev);
  514. iio_device_unregister(indio_dev);
  515. if (data->eoc_irq)
  516. free_irq(data->eoc_irq, data);
  517. if (gpio_is_valid(data->eoc_gpio))
  518. gpio_free(data->eoc_gpio);
  519. iio_device_free(indio_dev);
  520. return 0;
  521. }
  522. static const struct i2c_device_id ak8975_id[] = {
  523. {"ak8975", AK8975},
  524. {"ak8963", AK8963},
  525. {}
  526. };
  527. MODULE_DEVICE_TABLE(i2c, ak8975_id);
  528. static const struct of_device_id ak8975_of_match[] = {
  529. { .compatible = "asahi-kasei,ak8975", },
  530. { .compatible = "ak8975", },
  531. { }
  532. };
  533. MODULE_DEVICE_TABLE(of, ak8975_of_match);
  534. static struct i2c_driver ak8975_driver = {
  535. .driver = {
  536. .name = "ak8975",
  537. .of_match_table = ak8975_of_match,
  538. .acpi_match_table = ACPI_PTR(ak_acpi_match),
  539. },
  540. .probe = ak8975_probe,
  541. .remove = ak8975_remove,
  542. .id_table = ak8975_id,
  543. };
  544. module_i2c_driver(ak8975_driver);
  545. MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
  546. MODULE_DESCRIPTION("AK8975 magnetometer driver");
  547. MODULE_LICENSE("GPL");