1 // SPDX-License-Identifier: GPL-2.0-only
3 * ADXL345 3-Axis Digital Accelerometer I2C driver
5 * Copyright (c) 2017 Eva Rachel Retuya <eraretuya@gmail.com>
7 * 7-bit I2C slave address: 0x1D (ALT ADDRESS pin tied to VDDIO) or
8 * 0x53 (ALT ADDRESS pin grounded)
11 #include <linux/i2c.h>
12 #include <linux/module.h>
13 #include <linux/regmap.h>
17 static const struct regmap_config adxl345_i2c_regmap_config
= {
22 static int adxl345_i2c_probe(struct i2c_client
*client
,
23 const struct i2c_device_id
*id
)
25 struct regmap
*regmap
;
30 regmap
= devm_regmap_init_i2c(client
, &adxl345_i2c_regmap_config
);
32 dev_err(&client
->dev
, "Error initializing i2c regmap: %ld\n",
34 return PTR_ERR(regmap
);
37 return adxl345_core_probe(&client
->dev
, regmap
, id
->driver_data
,
41 static int adxl345_i2c_remove(struct i2c_client
*client
)
43 return adxl345_core_remove(&client
->dev
);
46 static const struct i2c_device_id adxl345_i2c_id
[] = {
47 { "adxl345", ADXL345
},
48 { "adxl375", ADXL375
},
52 MODULE_DEVICE_TABLE(i2c
, adxl345_i2c_id
);
54 static const struct of_device_id adxl345_of_match
[] = {
55 { .compatible
= "adi,adxl345" },
56 { .compatible
= "adi,adxl375" },
60 MODULE_DEVICE_TABLE(of
, adxl345_of_match
);
62 static struct i2c_driver adxl345_i2c_driver
= {
64 .name
= "adxl345_i2c",
65 .of_match_table
= adxl345_of_match
,
67 .probe
= adxl345_i2c_probe
,
68 .remove
= adxl345_i2c_remove
,
69 .id_table
= adxl345_i2c_id
,
72 module_i2c_driver(adxl345_i2c_driver
);
74 MODULE_AUTHOR("Eva Rachel Retuya <eraretuya@gmail.com>");
75 MODULE_DESCRIPTION("ADXL345 3-Axis Digital Accelerometer I2C driver");
76 MODULE_LICENSE("GPL v2");