Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * I2C IIO driver for Bosch BMA400 triaxial acceleration sensor.
0004  *
0005  * Copyright 2019 Dan Robertson <dan@dlrobertson.com>
0006  *
0007  * I2C address is either 0x14 or 0x15 depending on SDO
0008  */
0009 #include <linux/i2c.h>
0010 #include <linux/mod_devicetable.h>
0011 #include <linux/module.h>
0012 #include <linux/regmap.h>
0013 
0014 #include "bma400.h"
0015 
0016 static int bma400_i2c_probe(struct i2c_client *client,
0017                 const struct i2c_device_id *id)
0018 {
0019     struct regmap *regmap;
0020 
0021     regmap = devm_regmap_init_i2c(client, &bma400_regmap_config);
0022     if (IS_ERR(regmap)) {
0023         dev_err(&client->dev, "failed to create regmap\n");
0024         return PTR_ERR(regmap);
0025     }
0026 
0027     return bma400_probe(&client->dev, regmap, client->irq, id->name);
0028 }
0029 
0030 static const struct i2c_device_id bma400_i2c_ids[] = {
0031     { "bma400", 0 },
0032     { }
0033 };
0034 MODULE_DEVICE_TABLE(i2c, bma400_i2c_ids);
0035 
0036 static const struct of_device_id bma400_of_i2c_match[] = {
0037     { .compatible = "bosch,bma400" },
0038     { }
0039 };
0040 MODULE_DEVICE_TABLE(of, bma400_of_i2c_match);
0041 
0042 static struct i2c_driver bma400_i2c_driver = {
0043     .driver = {
0044         .name = "bma400",
0045         .of_match_table = bma400_of_i2c_match,
0046     },
0047     .probe    = bma400_i2c_probe,
0048     .id_table = bma400_i2c_ids,
0049 };
0050 
0051 module_i2c_driver(bma400_i2c_driver);
0052 
0053 MODULE_AUTHOR("Dan Robertson <dan@dlrobertson.com>");
0054 MODULE_DESCRIPTION("Bosch BMA400 triaxial acceleration sensor (I2C)");
0055 MODULE_LICENSE("GPL");
0056 MODULE_IMPORT_NS(IIO_BMA400);