Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / iio / magnetometer / rm3100-i2c.c
bloba09a271b62c5d23f5010bb4fd3001db5f76b9077
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Support for PNI RM3100 3-axis geomagnetic sensor on a i2c bus.
5 * Copyright (C) 2018 Song Qiang <songqiang1304521@gmail.com>
7 * i2c slave address: 0x20 + SA1 << 1 + SA0.
8 */
10 #include <linux/i2c.h>
11 #include <linux/module.h>
13 #include "rm3100.h"
15 static const struct regmap_config rm3100_regmap_config = {
16 .reg_bits = 8,
17 .val_bits = 8,
19 .rd_table = &rm3100_readable_table,
20 .wr_table = &rm3100_writable_table,
21 .volatile_table = &rm3100_volatile_table,
23 .cache_type = REGCACHE_RBTREE,
26 static int rm3100_probe(struct i2c_client *client)
28 struct regmap *regmap;
30 regmap = devm_regmap_init_i2c(client, &rm3100_regmap_config);
31 if (IS_ERR(regmap))
32 return PTR_ERR(regmap);
34 return rm3100_common_probe(&client->dev, regmap, client->irq);
37 static const struct of_device_id rm3100_dt_match[] = {
38 { .compatible = "pni,rm3100", },
39 { }
41 MODULE_DEVICE_TABLE(of, rm3100_dt_match);
43 static struct i2c_driver rm3100_driver = {
44 .driver = {
45 .name = "rm3100-i2c",
46 .of_match_table = rm3100_dt_match,
48 .probe = rm3100_probe,
50 module_i2c_driver(rm3100_driver);
52 MODULE_AUTHOR("Song Qiang <songqiang1304521@gmail.com>");
53 MODULE_DESCRIPTION("PNI RM3100 3-axis magnetometer i2c driver");
54 MODULE_LICENSE("GPL v2");
55 MODULE_IMPORT_NS("IIO_RM3100");