Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * BMI160 - Bosch IMU, I2C bits
0004  *
0005  * Copyright (c) 2016, Intel Corporation.
0006  *
0007  * 7-bit I2C slave address is:
0008  *      - 0x68 if SDO is pulled to GND
0009  *      - 0x69 if SDO is pulled to VDDIO
0010  */
0011 #include <linux/i2c.h>
0012 #include <linux/mod_devicetable.h>
0013 #include <linux/module.h>
0014 #include <linux/regmap.h>
0015 
0016 #include "bmi160.h"
0017 
0018 static int bmi160_i2c_probe(struct i2c_client *client,
0019                 const struct i2c_device_id *id)
0020 {
0021     struct regmap *regmap;
0022     const char *name;
0023 
0024     regmap = devm_regmap_init_i2c(client, &bmi160_regmap_config);
0025     if (IS_ERR(regmap)) {
0026         dev_err(&client->dev, "Failed to register i2c regmap: %pe\n",
0027             regmap);
0028         return PTR_ERR(regmap);
0029     }
0030 
0031     if (id)
0032         name = id->name;
0033     else
0034         name = dev_name(&client->dev);
0035 
0036     return bmi160_core_probe(&client->dev, regmap, name, false);
0037 }
0038 
0039 static const struct i2c_device_id bmi160_i2c_id[] = {
0040     {"bmi160", 0},
0041     {}
0042 };
0043 MODULE_DEVICE_TABLE(i2c, bmi160_i2c_id);
0044 
0045 static const struct acpi_device_id bmi160_acpi_match[] = {
0046     {"BMI0160", 0},
0047     { },
0048 };
0049 MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);
0050 
0051 static const struct of_device_id bmi160_of_match[] = {
0052     { .compatible = "bosch,bmi160" },
0053     { },
0054 };
0055 MODULE_DEVICE_TABLE(of, bmi160_of_match);
0056 
0057 static struct i2c_driver bmi160_i2c_driver = {
0058     .driver = {
0059         .name           = "bmi160_i2c",
0060         .acpi_match_table   = bmi160_acpi_match,
0061         .of_match_table     = bmi160_of_match,
0062     },
0063     .probe      = bmi160_i2c_probe,
0064     .id_table   = bmi160_i2c_id,
0065 };
0066 module_i2c_driver(bmi160_i2c_driver);
0067 
0068 MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com>");
0069 MODULE_DESCRIPTION("BMI160 I2C driver");
0070 MODULE_LICENSE("GPL v2");
0071 MODULE_IMPORT_NS(IIO_BMI160);