bmi160_i2c.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * BMI160 - Bosch IMU, I2C bits
  4. *
  5. * Copyright (c) 2016, Intel Corporation.
  6. *
  7. * 7-bit I2C slave address is:
  8. * - 0x68 if SDO is pulled to GND
  9. * - 0x69 if SDO is pulled to VDDIO
  10. */
  11. #include <linux/i2c.h>
  12. #include <linux/mod_devicetable.h>
  13. #include <linux/module.h>
  14. #include <linux/regmap.h>
  15. #include "bmi160.h"
  16. static int bmi160_i2c_probe(struct i2c_client *client,
  17. const struct i2c_device_id *id)
  18. {
  19. struct regmap *regmap;
  20. const char *name;
  21. regmap = devm_regmap_init_i2c(client, &bmi160_regmap_config);
  22. if (IS_ERR(regmap)) {
  23. dev_err(&client->dev, "Failed to register i2c regmap: %pe\n",
  24. regmap);
  25. return PTR_ERR(regmap);
  26. }
  27. if (id)
  28. name = id->name;
  29. else
  30. name = dev_name(&client->dev);
  31. return bmi160_core_probe(&client->dev, regmap, name, false);
  32. }
  33. static const struct i2c_device_id bmi160_i2c_id[] = {
  34. {"bmi160", 0},
  35. {}
  36. };
  37. MODULE_DEVICE_TABLE(i2c, bmi160_i2c_id);
  38. static const struct acpi_device_id bmi160_acpi_match[] = {
  39. {"BMI0160", 0},
  40. { },
  41. };
  42. MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);
  43. static const struct of_device_id bmi160_of_match[] = {
  44. { .compatible = "bosch,bmi160" },
  45. { },
  46. };
  47. MODULE_DEVICE_TABLE(of, bmi160_of_match);
  48. static struct i2c_driver bmi160_i2c_driver = {
  49. .driver = {
  50. .name = "bmi160_i2c",
  51. .acpi_match_table = bmi160_acpi_match,
  52. .of_match_table = bmi160_of_match,
  53. },
  54. .probe = bmi160_i2c_probe,
  55. .id_table = bmi160_i2c_id,
  56. };
  57. module_i2c_driver(bmi160_i2c_driver);
  58. MODULE_AUTHOR("Daniel Baluta <[email protected]>");
  59. MODULE_DESCRIPTION("BMI160 I2C driver");
  60. MODULE_LICENSE("GPL v2");
  61. MODULE_IMPORT_NS(IIO_BMI160);