staging: rtl8188eu: rename HalSetBrateCfg() - style
[linux/fpc-iii.git] / drivers / iio / accel / adxl345_i2c.c
blobf22f71315a0cdb912ffef6d5ed70adcfcfb7b71d
1 /*
2 * ADXL345 3-Axis Digital Accelerometer I2C driver
4 * Copyright (c) 2017 Eva Rachel Retuya <eraretuya@gmail.com>
6 * This file is subject to the terms and conditions of version 2 of
7 * the GNU General Public License. See the file COPYING in the main
8 * directory of this archive for more details.
10 * 7-bit I2C slave address: 0x1D (ALT ADDRESS pin tied to VDDIO) or
11 * 0x53 (ALT ADDRESS pin grounded)
14 #include <linux/i2c.h>
15 #include <linux/module.h>
16 #include <linux/regmap.h>
18 #include "adxl345.h"
20 static const struct regmap_config adxl345_i2c_regmap_config = {
21 .reg_bits = 8,
22 .val_bits = 8,
25 static int adxl345_i2c_probe(struct i2c_client *client,
26 const struct i2c_device_id *id)
28 struct regmap *regmap;
30 if (!id)
31 return -ENODEV;
33 regmap = devm_regmap_init_i2c(client, &adxl345_i2c_regmap_config);
34 if (IS_ERR(regmap)) {
35 dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
36 PTR_ERR(regmap));
37 return PTR_ERR(regmap);
40 return adxl345_core_probe(&client->dev, regmap, id->driver_data,
41 id->name);
44 static int adxl345_i2c_remove(struct i2c_client *client)
46 return adxl345_core_remove(&client->dev);
49 static const struct i2c_device_id adxl345_i2c_id[] = {
50 { "adxl345", ADXL345 },
51 { "adxl375", ADXL375 },
52 { }
55 MODULE_DEVICE_TABLE(i2c, adxl345_i2c_id);
57 static const struct of_device_id adxl345_of_match[] = {
58 { .compatible = "adi,adxl345" },
59 { .compatible = "adi,adxl375" },
60 { },
63 MODULE_DEVICE_TABLE(of, adxl345_of_match);
65 static struct i2c_driver adxl345_i2c_driver = {
66 .driver = {
67 .name = "adxl345_i2c",
68 .of_match_table = adxl345_of_match,
70 .probe = adxl345_i2c_probe,
71 .remove = adxl345_i2c_remove,
72 .id_table = adxl345_i2c_id,
75 module_i2c_driver(adxl345_i2c_driver);
77 MODULE_AUTHOR("Eva Rachel Retuya <eraretuya@gmail.com>");
78 MODULE_DESCRIPTION("ADXL345 3-Axis Digital Accelerometer I2C driver");
79 MODULE_LICENSE("GPL v2");