1 // SPDX-License-Identifier: GPL-2.0-only
3 * ADXL313 3-Axis Digital Accelerometer
5 * Copyright (c) 2021 Lucas Stankus <lucas.p.stankus@gmail.com>
7 * Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL313.pdf
10 #include <linux/i2c.h>
11 #include <linux/mod_devicetable.h>
12 #include <linux/module.h>
13 #include <linux/regmap.h>
17 static const struct regmap_config adxl313_i2c_regmap_config = {
20 .rd_table = &adxl313_readable_regs_table,
21 .wr_table = &adxl313_writable_regs_table,
25 static int adxl313_i2c_probe(struct i2c_client *client)
27 struct regmap *regmap;
29 regmap = devm_regmap_init_i2c(client, &adxl313_i2c_regmap_config);
31 dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
33 return PTR_ERR(regmap);
36 return adxl313_core_probe(&client->dev, regmap, client->name, NULL);
39 static const struct i2c_device_id adxl313_i2c_id[] = {
44 MODULE_DEVICE_TABLE(i2c, adxl313_i2c_id);
46 static const struct of_device_id adxl313_of_match[] = {
47 { .compatible = "adi,adxl313" },
51 MODULE_DEVICE_TABLE(of, adxl313_of_match);
53 static struct i2c_driver adxl313_i2c_driver = {
55 .name = "adxl313_i2c",
56 .of_match_table = adxl313_of_match,
58 .probe_new = adxl313_i2c_probe,
59 .id_table = adxl313_i2c_id,
62 module_i2c_driver(adxl313_i2c_driver);
64 MODULE_AUTHOR("Lucas Stankus <lucas.p.stankus@gmail.com>");
65 MODULE_DESCRIPTION("ADXL313 3-Axis Digital Accelerometer I2C driver");
66 MODULE_LICENSE("GPL v2");