1465c811fSDan Robertson // SPDX-License-Identifier: GPL-2.0-only
2465c811fSDan Robertson /*
3465c811fSDan Robertson * I2C IIO driver for Bosch BMA400 triaxial acceleration sensor.
4465c811fSDan Robertson *
5465c811fSDan Robertson * Copyright 2019 Dan Robertson <dan@dlrobertson.com>
6465c811fSDan Robertson *
7465c811fSDan Robertson * I2C address is either 0x14 or 0x15 depending on SDO
8465c811fSDan Robertson */
9465c811fSDan Robertson #include <linux/i2c.h>
10465c811fSDan Robertson #include <linux/mod_devicetable.h>
11465c811fSDan Robertson #include <linux/module.h>
12465c811fSDan Robertson #include <linux/regmap.h>
13465c811fSDan Robertson
14465c811fSDan Robertson #include "bma400.h"
15465c811fSDan Robertson
bma400_i2c_probe(struct i2c_client * client)16e599500fSUwe Kleine-König static int bma400_i2c_probe(struct i2c_client *client)
17465c811fSDan Robertson {
18e599500fSUwe Kleine-König const struct i2c_device_id *id = i2c_client_get_device_id(client);
19465c811fSDan Robertson struct regmap *regmap;
20465c811fSDan Robertson
21465c811fSDan Robertson regmap = devm_regmap_init_i2c(client, &bma400_regmap_config);
22465c811fSDan Robertson if (IS_ERR(regmap)) {
23465c811fSDan Robertson dev_err(&client->dev, "failed to create regmap\n");
24465c811fSDan Robertson return PTR_ERR(regmap);
25465c811fSDan Robertson }
26465c811fSDan Robertson
27ffe0ab6aSJagath Jog J return bma400_probe(&client->dev, regmap, client->irq, id->name);
28465c811fSDan Robertson }
29465c811fSDan Robertson
30465c811fSDan Robertson static const struct i2c_device_id bma400_i2c_ids[] = {
31*4391affaSUwe Kleine-König { "bma400" },
32465c811fSDan Robertson { }
33465c811fSDan Robertson };
34465c811fSDan Robertson MODULE_DEVICE_TABLE(i2c, bma400_i2c_ids);
35465c811fSDan Robertson
36465c811fSDan Robertson static const struct of_device_id bma400_of_i2c_match[] = {
37465c811fSDan Robertson { .compatible = "bosch,bma400" },
38465c811fSDan Robertson { }
39465c811fSDan Robertson };
40465c811fSDan Robertson MODULE_DEVICE_TABLE(of, bma400_of_i2c_match);
41465c811fSDan Robertson
42465c811fSDan Robertson static struct i2c_driver bma400_i2c_driver = {
43465c811fSDan Robertson .driver = {
44465c811fSDan Robertson .name = "bma400",
45465c811fSDan Robertson .of_match_table = bma400_of_i2c_match,
46465c811fSDan Robertson },
477cf15f42SUwe Kleine-König .probe = bma400_i2c_probe,
48465c811fSDan Robertson .id_table = bma400_i2c_ids,
49465c811fSDan Robertson };
50465c811fSDan Robertson
51465c811fSDan Robertson module_i2c_driver(bma400_i2c_driver);
52465c811fSDan Robertson
53465c811fSDan Robertson MODULE_AUTHOR("Dan Robertson <dan@dlrobertson.com>");
54465c811fSDan Robertson MODULE_DESCRIPTION("Bosch BMA400 triaxial acceleration sensor (I2C)");
55465c811fSDan Robertson MODULE_LICENSE("GPL");
56f9c02c94SJonathan Cameron MODULE_IMPORT_NS(IIO_BMA400);
57